IDictionary<string, string> dict = new Dictionary<string, string>();
NameValueCollection collection = new NameValueCollection();
collection.Add("1", "Ram");
collection.Add("2", "Shyam");
collection.Add("3", "Ghanshyam");
collection.Add("4", "Laxman");
//Lambda Expression
dict = collection.AllKeys.ToDictionary(k => k, k
=> collection[k]);
//OR
//Loop
foreach (var k in collection.AllKeys)
{
dict.Add(k,
collection[k]);
}
No comments:
Post a Comment