Concise code
Yesterday when porting LinqtoCRM to VS 2008 Beta 2, I had to get an array of the types of the properties of some generic type. This array would be passed to Type.GetConstructor(). I had an array of PropertyInfos which contain the type of the property, and I could have new’ed up an array and looped the types into that. Instead I did this:
PropertyInfo[] props = typeof(T).GetProperties(); Type[] types = props.Select(p => p.PropertyType).ToArray(); ConstructorInfo cInf = typeof(T).GetConstructor(types);
Leave a Reply