0
Can someone give an example of using setter, please?
1 Answer
+ 2
Hi Dimash, you can use setters to verify inputs, for example:
public string Name
{
get
{
return name;
}
set
{
if (value.Count(s => Char.IsDigit(s)) > 0)
{
Console.WriteLine("Only letters allowed");
}
name = value;
}
}