日期:2014-05-20 浏览次数:20939 次
[TestMethod] public void Test01() { IEnumerable<IGrouping<System.Reflection.MemberTypes, System.Reflection.MemberInfo>> group = typeof(String).GetMembers(). GroupBy(member => member.MemberType); foreach (IGrouping<System.Reflection.MemberTypes, System.Reflection.MemberInfo> g in group) foreach (System.Reflection.MemberInfo mi in g) Console.WriteLine(g.Key + ":" + mi.Name); typeof(String).GetMembers() .Select(p => new { MemberTypesName = p.MemberType.ToString(), MemberInfo = p.Name }) .Distinct() .GroupBy(p => p.MemberTypesName) .ToList() .ForEach(p => p.ToList().ForEach(p1 => Console.WriteLine(p1.MemberTypesName + ":" + p1.MemberInfo))); }