Last active
March 12, 2018 11:31
-
-
Save Plus1XP/82b05fcde5a4c57bb50a79eef6cebd41 to your computer and use it in GitHub Desktop.
Set logic for a Property
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
private int this.age; | |
public int Age | |
{ | |
get | |
{ | |
return this.age; | |
} | |
set | |
{ | |
if (value > 100) | |
throw new InvalidDataException("Person's age can not be more than 100 (or any valid business value)."); | |
this.age = value; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment