Skip to content

Instantly share code, notes, and snippets.

@Plus1XP
Last active March 12, 2018 11:31
Show Gist options
  • Save Plus1XP/82b05fcde5a4c57bb50a79eef6cebd41 to your computer and use it in GitHub Desktop.
Save Plus1XP/82b05fcde5a4c57bb50a79eef6cebd41 to your computer and use it in GitHub Desktop.
Set logic for a Property
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