how to convert a HashTable to Dictionary in C#? is it possible? for example if I have collection of objects in HashTable and if I want to convert it to a dictionary of objec
Extension method version of agent-j's answer:
using System.Collections;
using System.Collections.Generic;
using System.Linq;
public static class Extensions {
public static Dictionary ToDictionary (this Hashtable table)
{
return table
.Cast ()
.ToDictionary (kvp => (K)kvp.Key, kvp => (V)kvp.Value);
}
}