troubleshooting Question

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

Avatar of Rob Siklos
Rob SiklosFlag for Canada asked on
.NET Programming
2 Comments1 Solution446 ViewsLast Modified:
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?
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros