Last active
November 5, 2020 20:48
-
-
Save lomholdt/ac8d5dc65c71f102b81ccd7e50c6a49c to your computer and use it in GitHub Desktop.
Ensure not null
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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