Added nullable helper for IfNullOrWhiteSpace (#12979)

* Added nullable helper for IfNullOrWhiteSpace

* Remove for str as that one could be an empty string
This commit is contained in:
patrickdemooij9
2022-09-16 01:14:23 +02:00
committed by GitHub
parent b84ccea96f
commit 6d27454ed2

View File

@@ -419,7 +419,8 @@ public static class StringExtensions
/// returns <see langword="false" />.
/// </returns>
public static bool IsNullOrWhiteSpace(this string? value) => string.IsNullOrWhiteSpace(value);
[return: NotNullIfNotNull("defaultValue")]
public static string? IfNullOrWhiteSpace(this string? str, string? defaultValue) =>
str.IsNullOrWhiteSpace() ? defaultValue : str;