How can I get a propertydescriptor directly

  • Thread starter Thread starter Peter
  • Start date Start date
P

Peter

Hi

i have a class eg.

class Person
{
public string surname...
public string phone....
}

i know, its possible to get a propertydescriptor with the name
(string) or index (int)

o = new person()

propertydescriptor pd =TypeDescriptor.GetProperties(o)["phone"]

OK

but how can i get the propertydescriptor directly (without the name
oder index)
like " propertydescriptor pd = ....GetPropertyDescriptor(o.phone) "

thanks
Peter
 
Peter,

You can't really. I mean, you seem to have a string representing the
property already (if you can type "phone" in the code, then you can create a
constant string called "phone" and use that). Other than that, there is no
intrinsic way (a la typeof) that you can use to get a property descriptor.

Hope this helps.
 
Back
Top