From f5904ada4cb559bffd45d5c9361f6665c9db405d Mon Sep 17 00:00:00 2001 From: Jack Kanarish Date: Thu, 14 Dec 2017 12:15:56 -0500 Subject: [PATCH] add isnullorwhitespace helper --- ICD.Common.Utils/StringUtils.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ICD.Common.Utils/StringUtils.cs b/ICD.Common.Utils/StringUtils.cs index 5743312..8d8c0c8 100644 --- a/ICD.Common.Utils/StringUtils.cs +++ b/ICD.Common.Utils/StringUtils.cs @@ -475,6 +475,21 @@ namespace ICD.Common.Utils return text == null ? null : new string(text.Where(c => !Char.IsWhiteSpace(c)).ToArray()); } + /// + /// Returns true if the string is entirely whitespace characters, or empty, or null. + /// + /// + /// + public static bool IsNullOrWhitespace(string text) + { + if (string.IsNullOrEmpty(text)) + { + return true; + } + var trimmed = text.Trim(); + return trimmed.Length == 0; + } + /// /// Returns the password as a series of *s ///