I have the following class:
public class MyDict: ConcurrentDictionary<int, string>
{
public GenerateContent()
{
for(int i = 0 ; i < 10 ; i++)
{
this.TryAdd(i, i.ToString());
}
base = this.OrderByDescending(v => v.Key); // --> Error
}
}
After adding some values to the base class, I would like to sort it. But ConcurrentDictionary<>
does not offer a Sort()
method. Therefore I used OrderByDescending()
. But this method does not change the original object. It returns a new one instead.
Is there a way to sort the dictionary?