Click here to Skip to main content
Click here to Skip to main content
Alternative Tip

Tagged as

Go to top

.NET 4: string.IsNullOrWhitespace()

, 12 Aug 2010
Rate this:
Please Sign up or sign in to vote.
public static class StringExtensions { public static bool IsNullOrWhitespace(this string s) { if (null == s) return true; return string.IsNullOrEmpty(s.Trim()); } }
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)

Share

About the Author

jfriedman
Software Developer (Senior) ASTI Transportation Inc.
United States United States
Livin in a lonely world, caught the midnight train going anywhere... Only thing is it was a runaway train... and it ain't ever goin back...
 
v//
Follow on   Twitter   Google+

Comments and Discussions

 
GeneralThank you for clarifying however... Whitespace variants can... Pinmemberjfriedman13-Aug-10 10:30 
GeneralRe: I assist carrol_jhara in the broader definition of <B>White<... PinmemberAndreas Gieriet26-Feb-12 10:48 
GeneralReason for my vote of 2 will fail on whitespaces variants Pinmembercarrol_jhara12-Aug-10 18:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140926.1 | Last Updated 12 Aug 2010
Article Copyright 2010 by jfriedman
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid