Link to home
Create AccountLog in
Avatar of Rob Siklos
Rob SiklosFlag for Canada

asked on

Can I use reflection to discover if a property is auto-implemented?

I am using reflection in .NET 3.5, and I want to discover if a property of a class is implemented by the developer, or auto-implemented (http://msdn.microsoft.com/en-us/library/bb384054.aspx).

For instance, this property is implemented by the developer:
 
  private string myField = "";
  public string RegularProp {
     get { return myField;}
     set { myField = value; }
  }

And this property is auto-implemented:

  public string AutoProp {get; set; }


Can anyone find a way to make the distinction between regular and auto-implemented properties using reflection?
ASKER CERTIFIED SOLUTION
Avatar of scuzzie
scuzzie
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Rob Siklos

ASKER

Yes - I think you're right.