Monday, June 7, 2021

Automatic Properties

 Automatic Properties are used when no additional logic is required in the property accessors.

The declaration would look something like this:

public int SomeProperty { get; set; }

They are just syntactic sugar so you won't need to write the following more lengthy code:

 private int _someField;
 public int SomeProperty 
 {
    get { return _someField;}
    set { _someField = value;}
 }
Source : https://stackoverflow.com/questions/6001917/what-are-automatic-properties-in-c-sharp-and-what-is-their-purpose

No comments:

Followers

Link