Fill Array List with All properties of a class

Following Method/function will return list of class properties in an array list.

PropertyInfo class is is used to get the properties of the object passed to the method parameter. You may need to add System.Refelection directive in your page.

I am using this in my web development. Microsoft c-sharp , .net, .aspx

private ArrayList getPropertis(object obj)

{Type objtype = obj.GetType();

ArrayList arrayproperties = new ArrayList();foreach (PropertyInfo pi in objtype.GetProperties()){

arrayproperties.Add(pi.Name);}return arrayproperties;}

Tags: , , , , , ,

Comments are closed.