Created
May 15, 2014 16:31
-
-
Save jsonmez/001f412f4eb1178f1f6e to your computer and use it in GitHub Desktop.
Age Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ValidateCustomer(int maximumAge) | |
{ | |
//... | |
} | |
ValidateCustomer(25); | |
// Using an Age class to restrict values | |
public class Age | |
{ | |
public Age(int age) | |
{ | |
if(age < 0 || age > 130) | |
throw new Exception("Invalid age. Age must be between 0 and 130"); | |
} | |
} | |
public void ValidateCustomer(Age maximumAge) | |
{ | |
// ... | |
} | |
var customerAge = new Age(25); | |
ValidateCustomer(age); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment