diff --git a/X10D/src/StringExtensions.cs b/X10D/src/StringExtensions.cs index a462ad4..50a80a8 100644 --- a/X10D/src/StringExtensions.cs +++ b/X10D/src/StringExtensions.cs @@ -12,6 +12,27 @@ /// public static class StringExtensions { + /// + /// Returns the current string, or if the current string is null or empty. + /// + /// The value to sanitize. + /// or . + public static string? AsNullIfEmpty(this string value) + { + return string.IsNullOrEmpty(value) ? null : value; + } + + /// + /// Returns the current string, or if the current string is null, empty, or consists of only + /// whitespace. + /// + /// The value to sanitize. + /// or . + public static string? AsNullIfWhiteSpace(this string value) + { + return string.IsNullOrWhiteSpace(value) ? null : value; + } + /// /// Decodes a base-64 encoded string. ///