/// <summary>Trim the ToString() of the object; returning null if null, empty, or whitespace.</summary>
/// <param name="self"></param>
/// <returns></returns>
[DebuggerStepThrough]
[CanBeNull]
[Pure]
public static String? Trimmed<T>( [CanBeNull] this T self ) =>
self switch {
null => default( String? ),
String s => s.Trim().NullIfEmpty(),
var _ => self.ToString()?.Trim().NullIfEmpty()
};
Like this:
Like Loading...
Related
Published by Protiguous
C# Software Developer, SQL Server DBA, Father, and seeker of Truth.
View all posts by Protiguous