Let us see the SET , GET with simple explanation
GET
The body of the get accessor is similar to that of a method. It must return a value of the property type.
SET
The set accessor is similar to a method whose return type is void. It uses an implicit parameter called value, whose type is the type of the property
class PDetails
{
private string name; // the name field
public string Name // the Name property
{
get { return name; }
set{ name = value; }
}
}
From Outer Class
PDetails obj = new PDetails();
obj .Name = “Joe”; // the set accessor is invoked here
System.Console.Write(obj .Name); // the get accessor is invoked here