C# BestPractice: Private var and Public Getter/Setter or Public Var
- by Desiny
What are the advantages and differences between the below two coding styles...
public void HelloWorld () {
private string _hello;
public string Hello {
get
{
return _hello;
}
set
{
_hello = value;
}
}
}
or
public void HelloWorld () {
public string Hello { get; set; }
}
My preference is for short simple code, but interested to hear opinions as I see many developers who insist on the long route.