c# property setter only by method code example
Example 1: c# accessors
private string _name = "Hello";
public string Name
{
get
{
return _name;
}
protected set
{
_name = value;
}
}
Example 2: getter setter c#
class Student
{
public int Age { get; set; }
}