Home

isNullOrWhiteSpace

IsNullOrWhiteSpace is a static method in the .NET framework and .NET Core class System.String. It determines whether a given string is null, empty, or consists solely of white-space characters.

The method returns a boolean value. It returns true if the input string is null, if its

This method is commonly used to validate input before processing to avoid null reference errors or to

Difference from related checks: String.IsNullOrWhiteSpace differs from String.IsNullOrEmpty, which returns true only for null or empty

Usage examples: String.IsNullOrWhiteSpace(null) yields true; String.IsNullOrWhiteSpace(" ") yields true; String.IsNullOrWhiteSpace("text") yields false.

Notes: The method relies on Unicode-based whitespace definitions via Char.IsWhiteSpace, making it culture-insensitive. It was introduced

length
is
zero,
or
if
every
character
in
the
string
is
classified
as
white
space
by
Char.IsWhiteSpace.
It
returns
false
for
any
string
that
contains
at
least
one
non-whitespace
character.
White-space
includes
spaces,
tabs,
newlines,
and
other
Unicode
whitespace
characters.
treat
blank
input
as
missing.
It
is
more
comprehensive
than
a
simple
null-or-empty
check
because
it
also
recognizes
strings
that
appear
blank
due
to
whitespace
only.
strings
and
does
not
consider
whitespace-only
strings
as
empty.
In
contrast,
IsNullOrWhiteSpace
treats
whitespace-only
strings
as
effectively
empty.
with
the
.NET
Framework
4.0
and
is
available
in
.NET
Core
and
later
runtimes.
See
also
String.IsNullOrEmpty
and
Char.IsWhiteSpace
for
related
checks.