Working with List collection ToDictionary method

Posted by Rajesh_Kumar under LINQ category on | Points: 40 | Views : 893
ToDictionary is a mthod available in List collection which converts any List collection into a Dictionary collection.

For Example:
List<string> lst_names = new List<string>()

var names = lst_names.ToDictionary(g => g, g => true);

if (names.ContainsKey("Rajesh"))
Response.Write("Rajesh is present in a list collection");

Output: Rajesh is present in a list collection

Comments or Responses

Login to post response