This example shows how we can get names of all properties for a specific type by using Type.GetProperties.
Example
PropertyInfo[] propertyInfoCollection; propertyInfoCollection = typeof(MyTestClass).GetProperties(BindingFlags.Public | BindingFlags.Static); // sorting property Array.Sort(propertyInfoCollection, delegate(PropertyInfo myPropertyInfo1, PropertyInfo myPropertyInfo2) { return myPropertyInfo1.Name.CompareTo(myPropertyInfo2.Name); }); // Displaying property names by iterating through collection foreach (PropertyInfo property in propertyInfoCollection) { Console.WriteLine(property.Name); } |

Leave a Reply
You must be logged in to post a comment.