Click here to Skip to main content
15,894,017 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
What is auto-implemented properties in all C# .
How and when to use it??
Is that specific to visual studio version.
Posted

Auto-implemented properties are only a syntactic shortcut to ordinary properties. The following auto-implemented property:

C#
public bool MyProperty { get; set; }


...is exactly the same like:

C#
private bool myField;
public bool MyProperty {
  get { return myField; }
  set { myField = value; }
}


If you use the auto-implemented property syntax, the compiler will generate the backing field and getter/setter. If you implement the property manually, you have to write more code but you have more control over the code inside getter/setter.
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900