Hey so I am currently writing a program for university and when creating my classes I am using get set my question is, is there an easier way than this method shown bellow to set things.
Code snippet showing my current way
private string customer_first_name;
private string customer_surname;
private string customer_address;
public DateTime arrival_time;
//Using accessors to get the private variables
//Using accessors to set the private variables
public string Customer_First_Name
{
get { return customer_first_name; }
set { customer_first_name = value; }
}
Use auto-implemented properties instead:
In this case compiler will generate field for storing property value.
BTW you can save even more time if you will use
propcode snippet in Visual Studio. Just start typingpropand hitTab– it will paste snippet for auto-generated property. All what you need – provide property name and type.