Skip to content

Instantly share code, notes, and snippets.

@loneshark99
Created February 10, 2018 02:49
Show Gist options
  • Save loneshark99/8c1a64a16d44bd14cbe371a387628f05 to your computer and use it in GitHub Desktop.
Save loneshark99/8c1a64a16d44bd14cbe371a387628f05 to your computer and use it in GitHub Desktop.
Guard class for Argument Validations.
public static class Guard
{
public static void NotNull<T>(string argumentName, T value)
where T : class
{
if (value == null)
throw new ArgumentNullException(argumentName);
}
public static void NotEmpty(string argumentName, string value)
{
if (String.IsNullOrWhiteSpace(value))
throw new ArgumentException("Non-empty string expected", argumentName);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment