from time to time, I see some sample code that is handed to me that has a code snippet that looks like this:
- public string Name { get; set; }
Does this actually do anything? Does it really make it so that one can set and get the "Name" string variable?
I have always thought that what is required is something like this:
- private string name;
- public string Name
- {
- get
- {
- return this.name;
- }
- set
- {
- this.name = value;
- }
- }
Am I correct?
Please advise.


James AxsomRank #4,887 · 320 reputationPosted Jun 29, 2018, 2:33 PM EDT
Gajanan ChavhanRank #1,826 · 812 reputationPosted Jul 1, 2018, 11:39 PM EDT
Tushar DikshitRank #1,378 · 1.2K reputationPosted Jun 29, 2018, 11:15 AM EDT
Rafnas T PRank #280 · 8.8K reputationPosted Jun 29, 2018, 5:36 PM EDT