Error handling in property setter validating : Properties « Class Interface « C# / C Sharp
- C# / C Sharp
- Class Interface
- Properties
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;
}
}
}
Related examples in the same category