Convert query to Dictionary

image_pdfimage_print
   
 
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());
   }
}

    


This entry was posted in LINQ. Bookmark the permalink.