In Which cases we can use get and set and How to use just one of them in programs?
Joe Wilson
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Apr 27, 2014, 10:55 AM EDT
Jignesh TrivediRank #16 · 50.3K reputationPosted Apr 27, 2014, 9:33 PM EDT
Agreee with Vulpes
When you are writing get and set with property is called Auto-Implemented Properties which is introduced in C#3.0. This is used when no additional logic required in the property accessors.
private string _name;
public string Name
{
get
{
return _name;
}
set
{
_name = value;
}
}
equivalent to....
public string Name { get; set; }
hope this will help you.