Convert query to Dictionary with ToDictionary in CSharp
Description
The following code shows how to convert query to Dictionary with ToDictionary.
Example
/*from www . j a va2 s. c o m*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
public class MainClass{
public static void Main(){
var q = from m in typeof(int).GetMethods()
group m by m.Name into gb
select gb;
Dictionary<string, int> d = q.ToDictionary(k => k.Key, k => k.Count());
}
}