Skip to content

Instantly share code, notes, and snippets.

@IanWold
Last active December 27, 2015 08:39
Show Gist options
  • Save IanWold/7297463 to your computer and use it in GitHub Desktop.
Save IanWold/7297463 to your computer and use it in GitHub Desktop.
When you need to check for null arguments
public static void ThrowArgNullException(params object[] args)
{
for (int i = 0; i < args.Count(); i++)
{
if (args[i] == null) throw new ArgumentNullException("Argument Number " + i);
}
}
public static void ThrowArgNullException(string[] ArgNames, params object[] args)
{
for (int i = 0; i < args.Count(); i++)
{
if (args[i] == null) throw new ArgumentNullException(ArgNames[i]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment