I am trying to convert a hashtable to disctionary and found a a question here: convert HashTable to Dictionary in C#
public static Dictionary<K,V> HashtableToDictionary<K,V> (Hashtable table)When I try to use it, there is an error in table.Cast; intellisense does not show "Cast" as a valid method.
{
return table
.Cast<DictionaryEntry> ()
.ToDictionary (kvp => (K)kvp.Key, kvp => (V)kvp.Value);
}
Pravesh Singh
17-Dec-2013Enumerable.Cast doesn't exist in .NET 2, nor does most of the LINQ related methods (such as ToDictionary).
You'll need to do this manually via looping: