Mega Code Archive

 
Categories / C# / Class Interface
 

Error handling in property setter validating

using System; public class Employee {     private int prop_age;     public int age {         set {             if (value < 0 || value > 120) {                 throw new ApplicationException("Not valid age!");             }             prop_age = value;         }         get {             return prop_age;         }     } }