diff --git a/X10D/src/StringExtensions.cs b/X10D/src/StringExtensions.cs
index 50a80a8..d722cd2 100644
--- a/X10D/src/StringExtensions.cs
+++ b/X10D/src/StringExtensions.cs
@@ -373,5 +373,27 @@
return TimeSpanParser.Parse(str);
}
+
+ ///
+ /// Returns the current string, or an alternative value if the current string is null or empty, or optionally if the
+ /// current string consists of only whitespace.
+ ///
+ /// The value to check.
+ /// The alternative value if does not meet the criteria.
+ ///
+ /// Optional. If set to , will be returned also if
+ /// only consists of whitespace.
+ ///
+ /// Returns or .
+ /// is .
+ public static string WithAlternative(this string? value, string alternative, bool includeWhiteSpace = false)
+ {
+ if (alternative is null)
+ {
+ throw new ArgumentNullException(nameof(alternative));
+ }
+
+ return (includeWhiteSpace ? value?.AsNullIfWhiteSpace() : value?.AsNullIfEmpty()) ?? alternative;
+ }
}
}