0

could someone explain to me what is the difference between writing a property like this

public string Name{  get; set;  }

and this

public string Name()
{
    get
    {
        return _name;
    }
    set
    {
        _name = value;
    }
}

if the top one is as easy to write/implement as it seems then why aren't all properties wrote in this fashion?

David
  • 11
  • 5
  • Because sometime you need to do something else that store value in getter or setter. Former is basically syntactic sugar for latter. – rholek Apr 15 '16 at 21:13
  • 1
    or [here](http://stackoverflow.com/questions/6001917/what-are-automatic-properties-in-c-sharp-and-what-is-their-purpose) – Jonesopolis Apr 15 '16 at 21:14

0 Answers0