Get/Set in C# easier way?

.net, c#, properties

Solution

Use auto-implemented properties instead:

public string Customer_First_Name { get; set; }

In this case compiler will generate field for storing property value.

BTW you can save even more time if you will use `prop` code snippet in Visual Studio. Just start typing `prop` and hit `Tab` - it will paste snippet for auto-generated property. All what you need - provide property name and type.

Problem

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; } } ```

Original source