I'm trying to get the last item in my ordered dictionary but it doesn't have the nice LINQ functions like a normal dictionary does such as .First() .Last()
I was just wondering if anyone knew how I could do this?
I'm trying to get the last item in my ordered dictionary but it doesn't have the nice LINQ functions like a normal dictionary does such as .First() .Last()
I was just wondering if anyone knew how I could do this?
The System.Collections.Specialized.OrderedDictionary class does not implement the generic interface IEnumerable<>, and therefore the extension methods you mention do not apply.
You can use .Cast<DictionaryEntry>() first. It can be used because it is based on the non-generic IEnumerable interface. It returns a generic IEnumerable<DictionaryEntry>, so you can use .Last() on that.
But it may be better to use a "newer" collection type.