Skip to content

Instantly share code, notes, and snippets.

@lomholdt
Last active November 5, 2020 20:48
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 lomholdt/ac8d5dc65c71f102b81ccd7e50c6a49c to your computer and use it in GitHub Desktop.
Save lomholdt/ac8d5dc65c71f102b81ccd7e50c6a49c to your computer and use it in GitHub Desktop.
Ensure not null
using System;
namespace Tools.Internal
{
internal static class Ensure
{
public static T NotNull<T>(T obj, string paramName)
where T : class
{
if (obj is null)
{
throw new ArgumentNullException(paramName);
}
return obj;
}
public static string NotNullOrEmpty(string obj, string paramName)
{
if (string.IsNullOrEmpty(obj))
{
throw new ArgumentException("Value cannot be null or an empty string.", paramName);
}
return obj;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment