Give a simple example of Get and Set property?

 Posted by Rajesh_Kumar on 2/14/2014 | Category: C# Interview questions | Views: 2606 | Points: 40
Answer:


public class Project_Master
{
private string _project_name;
public string Project_Name
{
get
{
return _project_name;
}
set
{
_project_name = value;
}
}
}


For assigning value to Project_Name property as
Project_Name = "abc"; - Set Property

to get thr value from Project_Name
string prj_name = Project_Name; - Get Property


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response