get the name of a property

  • Thread starter Thread starter A.Bekiaris
  • Start date Start date
A

A.Bekiaris

Is it possible to get the name of a property?



Something Like having a method that I could pass as argument the property of class and get back the propertyName

string name=GetPropertyName(class1.Property)
 
Not sure how you can do that specifically but I would start my search by
looking into Reflection. With Reflection you can interate through a class
and generate a list (strings) of all the methods, properties, etc.

- Jason
 
Hi Bekiaris,

As jason pointed out, you can do it using reflection.

Type <somename> =
Assembly.GetExecutingAssembly().GetType("<yournamespace.classname>");

someFieldInfo <handyfieldinfoName> =
<somename>.GetField("<staticvariablename>", BindingFlags.Static |
BindingFlags.SetProperty);

Gives you the set property of the class.

Try to loop thro' other functionalites under <somename> also.

Regards,

venkat.Murthy
 
Back
Top