Only the non-generic version of SortedList has that method. Remember that Foo<T> is not the same class as Foo (although one could subclass the other).


They both have an indexer though, I’d use that in both cases. Or actually, don’t use the non-generic one at all, it’ll cause tons of boxing.
Boxing….that’s a term I’ve not heard for a long time. Long time.
Guessing you cannot acces it by index since its a custom type array, so you must supply the key directly to get the value
https://docs.microsoft.com/en-us/dotnet/api/system.collections.sortedlist.getbyindex?view=net-5.0

https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.sortedlist-2?view=net-5.0

The class documentation is a magnificent help in times like this. Takes a little getting used to, as a class could be defined multiple times in different versions of the .NET Framework, or even “extended” by other DLLs, put those are relatively rare incidents. As long as one understands OOP and takes care to pay attention to the Version (top left drop down box. .NET 5.0 on those pages I linked).
Why not use indexer notation?
You can do this by using the Values property: https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.sortedlist-2.values?view=net-5.0
Not got a compiler to hand, but try 3M instead of 3. 3 is not a decimal (your key type).


C# devs
null reference exceptions

source