LINQ与反射

string file = @"C:\Windows\winsxs\x86_netfx35linq-system.core_31bf3856ad364e35_6.1.7601.17514_none_6161fc35ed136622\System.Core.dll";
            Assembly assembly = Assembly.LoadFrom(file);

            var pubTypeQuery = from type in assembly.GetTypes()
                               where type.IsPublic
                               from method in type.GetMethods()
                               where method.ReturnType == typeof(string)
                               group method.ToString() by type.ToString();

            foreach (var item in pubTypeQuery)
            {
                Console.WriteLine(item.Key);
                foreach (var item1 in item)
                {
                    Console.WriteLine(item1);                    
                }                
            }

            Console.WriteLine();
            Console.WriteLine("Press Any Key to Exit...");
            Console.ReadKey();

 

posted on 2016-03-21 16:42  雯大侠  阅读(190)  评论(0编辑  收藏  举报

导航