-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access SortedList<Tkey, TValue> by index #26591
Comments
@jkotas |
These methods do exist in .NET Framework 4.7.2. The doc has a drop down at the left side that lets you see all versions where the method is available. |
The end of doc sias:
|
Obviously this is not true, and I ask why, since MS always says that every thing added to .NET core, will eventually appear in .NET Framework ? |
@jkotas |
I have double check. These method are in .NET Framework 4.7.2. What makes you think that they are not there?
This is not a correct statement. It is not what we have been saying for a while. Where did you hear this? |
SortedList is part of the core framework. You do not need to reference any NuGet to get it - there is not any. |
I try this in a C# windows forms framework 4.7.2 project:
and C# doesn't find the method GetKey! |
@jkotas
|
@jkotas |
@jkotas |
I do not know either. Looks like you may be running into a bug in Visual Studio. You can report it using https://docs.microsoft.com/en-us/visualstudio/ide/talk-to-us |
@jkotas Maybe these methods exsist in a NuGet. |
@jkotas : |
Ah ok. Sorry about the confusion. On generic SortedList, this is available via indexers on Keys and Values properties. Try: SortedList<int, int> sl = new SortedList<int, int>();
for (int i = 0; i < 10; i++) sl.Add(i, i*i);
Console.WriteLine(sl.Keys[5]);
Console.WriteLine(sl.Values[5]); |
@jkotas |
SortedList<Tkey, TValue>
has these two methods:1- IndexOfKey
2- IndexOfValue
They return the index of the item in the sorted list, but there is no way to access any item by its index! The only method that uses the index is RemoveAt!
So, why there is no Indexer that accepts the index? This class is a LIST not a Dictionary, and lists are accessible by index.
The text was updated successfully, but these errors were encountered: