The more I use LINQ the more I love the power it brings to my code. Whenever I find my self looking at a enumerable type or method I’m curious how I can query the information.
Case in point. I needed to find only the properties on a type that are declared in that type, not in any of the base types. This simple LINQ snippet delivered the solution.
Type t = typeof(System.String); var q2 = from prop in t.GetProperties() where prop.DeclaringType == t orderby prop.Name select prop;
' In Visual Basic Dim t As Type = GetType(System.String) Dim q2 = From prop In t.GetProperties() _ Where prop.DeclaringType Is t _ Order By prop.Name _ Select prop