LINQ ToDictionary() MethodIn LINQ, ToDictionary() Method is used to convert the items of list/collection(IEnumerable<T>) to new dictionary object (Dictionary<TKey,TValue>) and it will optimize the list/collection items by required values only. Syntax of LINQ ToDictionary MethodHere is the syntax of using the LINQ ToDictionary() operator. C# Code In the above syntax, we are converting the collection of "objStudent" to dictionary object and getting the only required filled value (ID and Name). Example of ToDictionary methodHere is the example of using the LINQ ToDictionary operator to convert the collection to the new dictionary object. In the above example, we are converting the collection of "objStudent" to dictionary objects and getting the values from the two values (ID and Name). OUTPUT:
Next TopicLINQ Element Operators
|