Error handling in property setter validating : Properties : Class Interface C# Source Code


Custom Search

C# Source Code » 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;
        }
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Class Interface
» Properties