Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / programming / string

.NET 4: string.IsNullOrWhitespace()

3.33/5 (2 votes)
12 Aug 2010CPOL 16.2K  
public static class StringExtensions { public static bool IsNullOrWhitespace(this string s) { if (null == s) return true; return string.IsNullOrEmpty(s.Trim()); } }
C#
public static class StringExtensions
    {
        public static bool IsNullOrWhitespace(this string s)
        {
            if (null == s) return true;
            return string.IsNullOrEmpty(s.Trim());
        }
    }

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)