Search code examples
asp.netdictionarysorteddictionary

SortedDictionary 's Extension Method OrderByDescending is Not Available for Web Pages ASP.NET C#


I am trying to Sort the Items by Value in the SortedDictionary..

I had done that by mySortedDictionary.OrderByDescending(key => key.Value); it Returns the Sorted Key Value Pairs..

But in the same way I am using the OrderByDescending Method in ASP.NET web Page, But is says

System.Collections.Generic.SortedDictionary' does not contain a definition for 'OrderByDescending' and no extension method 'OrderByDescending' accepting a first argument of type 'System.Collections.Generic.SortedDictionary' could be found (are you missing a using directive or an assembly reference?)

How could I achieve this operation in my web page?

any alternative technique???

Thanks in Advance..


Solution

  • OrderByDescending is an extension method inside of System.Linq.

    Make sure you have the relevant using statemenet at the top of your class

    using System.Linq;