Skip to content

Instantly share code, notes, and snippets.

@mat-mcloughlin
Last active August 29, 2015 14:16
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 mat-mcloughlin/6f2082f0fc35c20c6573 to your computer and use it in GitHub Desktop.
Save mat-mcloughlin/6f2082f0fc35c20c6573 to your computer and use it in GitHub Desktop.
guard.cs
namespace Foo
{
using System;
internal static class Guard
{
internal static void EnsureNotNull(object argument, string argumentName)
{
if (argument == null)
{
throw new ArgumentNullException(argumentName);
}
}
internal static void EnsureNullOrWhiteSpace(string argument, string argumentName)
{
if (string.IsNullOrWhiteSpace(argument))
{
throw new ArgumentException(string.Format("{0} is null or whitespace",argumentName));
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment