0

Can someone give an example of using setter, please?

24th Jul 2016, 3:48 AM
Dimash Bekzhan
Dimash Bekzhan - avatar
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; } }
26th Jul 2016, 2:52 AM
Ricardo Pucca
Ricardo Pucca - avatar