Hi
I recently came to the C# world. I have seen many get/set method variations. Which one do you use and I should use?
I listed them below:
Code Code Code Code Code C# Code Code Code Code Code Code |
What are the differences between these. I like the last ones for their compactness.

Manikavelu VelayuthamRank #413 · 6K reputationPosted Sep 23, 2010, 4:34 AM EDT
Private means it will be like a read only.
public means you can get and set values to any property
Felipe RamosRank #1,409 · 1.2K reputationPosted Sep 23, 2010, 4:57 AM EDT
Moose Pickard64 reputationPosted Sep 23, 2010, 6:02 AM EDT
Does that mean that setting the variable can only be done in the same class?
If I make the set/get like in the first example I can call it also from a higher object. Say for example there is an instance of a Name object in the Person object:
Name M = new Name
M.Name = "John"
How would I do it with just the last get/set notation example (public string name { get; private set;})?
Also I am curios about the variable notation You, Felipe, use. The m_ in front, what does it stand for?
Felipe RamosRank #1,409 · 1.2K reputationPosted Sep 23, 2010, 6:26 AM EDT