C# get set

get set can get or set value of the specific property of a class object.

class human
{
public int age;
public string sex;
public human(int a, string s) {age=a;sex=s;}
public string isex
{
get
{
return sex;
}
set
{
sex = value;
}
}
}

Example of get and set the sex property of human object.
human John = new human(23, "Male");
System.Console.WriteLine(John.isex); //Male
John.isex = "Female";
System.Console.WriteLine(John.isex); //Female