Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 695881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:00:20+00:00 2026-05-14T03:00:20+00:00

What is needed to make String.IsNullOrEmpty() count whitespace strings as empty? Eg. I want

  • 0

What is needed to make String.IsNullOrEmpty() count whitespace strings as empty?

Eg. I want the following to return true instead of the usual false:

String.IsNullOrEmpty(" ");

Is there a better approach than:

 String.IsNullOrEmpty(" ".Trim());

(Note that the original question asked what the return would be normally hence the unsympathetic comments, this has been replaced with a more sensible question).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T03:00:21+00:00Added an answer on May 14, 2026 at 3:00 am

    .NET 4.0 will introduce the method String.IsNullOrWhiteSpace. Until then you’ll need to use Trim if you want to deal with white space strings the same way you deal with empty strings.

    For code not using .NET 4.0, a helper method to check for null or empty or whitespace strings can be implemented like this:

    public static bool IsNullOrWhiteSpace(string value)
    {
        if (String.IsNullOrEmpty(value))
        {
            return true;
        }
    
        return String.IsNullOrEmpty(value.Trim());
    }
    

    The String.IsNullOrEmpty will not perform any trimming and will just check if the string is a null reference or an empty string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I needed some simple string encryption, so I wrote the following code (with a
Let's say I needed to make a series of String[] objects. I know that
I execute the following commands to make the model: script/generate model user firstname:string lastname:string
Given a string, figure out how many characters minimum are needed to make the
Is good knowledge of PHP needed to make an installable template for CMS like
I have come across a Silverlight project that needed to make use of a
What's needed to succesfully make a crossdomain call from Silverlight?
I needed to find all the files that contained a specific string pattern. The
I've just installed this plugin, created the migrations, added everything I needed to make
The following code sort of works, but fixes the number of elements in String[].

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.