24 lines
632 B
C#
24 lines
632 B
C#
using System.Diagnostics.Contracts;
|
|
|
|
namespace bts.utils {
|
|
static class StringExtensions {
|
|
[Pure]
|
|
public static string EmptyIfNull(this string str) =>
|
|
str ?? "";
|
|
|
|
[Pure]
|
|
public static string NullIfEmpty(this string str) =>
|
|
str == "" ? null : str;
|
|
|
|
[Pure]
|
|
public static bool IsNullOrEmpty(this string str) =>
|
|
string.IsNullOrEmpty(str);
|
|
|
|
public static bool SafeContains(this string str, string value) =>
|
|
str != null && str.Contains(value);
|
|
|
|
public static string Copy(this string str) =>
|
|
string.Copy(str);
|
|
}
|
|
}
|