namespace Unity.Tutorials.Core.Editor { /// /// Extension methods for System.String. /// public static class StringExtensions { /// /// Indicates whether this string is null or an empty string (""). /// /// /// public static bool IsNullOrEmpty(this string self) => string.IsNullOrEmpty(self); /// /// Indicates whether this string is not null or an empty string (""). /// /// /// public static bool IsNotNullOrEmpty(this string self) => !self.IsNullOrEmpty(); /// /// Indicates whether this string is null, empty, or consists only of white-space characters. /// /// /// public static bool IsNullOrWhiteSpace(this string self) => string.IsNullOrWhiteSpace(self); /// /// Indicates whether this string is not null, empty, or consists only of white-space characters. /// /// /// public static bool IsNotNullOrWhiteSpace(this string self) => !self.IsNullOrWhiteSpace(); /// /// Returns null if this string is not null, empty, or consists only of white-space characters. /// /// /// public static string AsNullIfWhiteSpace(this string self) => string.IsNullOrWhiteSpace(self) ? null : self; /// /// Returns null if this string is null or an empty string (""). /// /// /// public static string AsNullIfEmpty(this string self) => self.IsNullOrEmpty() ? null : self; /// /// Returns an empty string ("") if this string is null. /// /// /// public static string AsEmptyIfNull(this string self) => self ?? string.Empty; } /// /// Static helper functions for System.String. /// Useful for example in LINQ queries. /// public static class StringExt { /// /// Indicates whether a specified string is null or an empty string (""). /// /// /// public static bool IsNotNullOrEmpty(string str) => !str.IsNullOrEmpty(); /// /// Indicates whether a specified string is not null, empty, or consists only of white-space characters. /// /// /// public static bool IsNotNullOrWhiteSpace(string str) => !string.IsNullOrWhiteSpace(str); } }