How do I defined property in C#?
-
Do Refer : 1. http://www.c-sharpcorner.com/UploadFile/rajeshvs/PropertiesInCS11122005001040AM/PropertiesInCS.aspx[^] 2. http://www.csharp-station.com/Tutorials/Lesson10.aspx[^] Hope this helps. All the best.
-
Hi, To add a property say Name do the following in your class. private string _name; public string Name { get{ return _name;} set {_name = value;} } hope this helps. Nitheesh George http://www.simpletools.co.in
-
Hi, To add a property say Name do the following in your class. private string _name; public string Name { get{ return _name;} set {_name = value;} } hope this helps. Nitheesh George http://www.simpletools.co.in
It does, but just as a note. In an instance like this it is cleaner to use the auto-property. public string name { get; set; } with no private member defined. (Your answer is still correct, of course)
I wasn't, now I am, then I won't be anymore.