Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@IntegerMan
Created October 16, 2019 01:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IntegerMan/ff298c638df39e13fbdabdb1285f9429 to your computer and use it in GitHub Desktop.
Save IntegerMan/ff298c638df39e13fbdabdb1285f9429 to your computer and use it in GitHub Desktop.
private void CheckInput(int input, [CallerMemberName] string methodName = "") {
if (input != 42) {
throw new ArgumentOutOfRangeException(nameof(input), $"{methodName} cannot be invoked with a non-42 value");
}
}
public void DoFoo(int input) {
CheckInput(input); // No longer passing in name
// ...
}
public void DoBar(int input) {
CheckInput(input); // No longer passing in name
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment