C# String IsNullOrWhiteSpace
Description
String IsNullOrWhiteSpace
indicates whether a specified
string is null, empty, or consists only of white-space characters.
Syntax
String.IsNullOrWhiteSpace
has the following syntax.
public static bool IsNullOrWhiteSpace(
string value
)
Parameters
String.IsNullOrWhiteSpace
has the following parameters.
value
- The string to test.
Returns
String.IsNullOrWhiteSpace
method returns true if the value parameter is null or String.Empty, or if value consists
exclusively of white-space characters.
Example
The following example creates a string array, and then passes each element of the array to the IsNullOrWhiteSpace method.
using System;// www. j a v a 2s.c o m
public class Example
{
public static void Main()
{
string[] values = { null, String.Empty, "ABCDE",
new String(' ', 20), " \t ",
new String('\u2000', 10) };
foreach (string value in values)
Console.WriteLine(String.IsNullOrWhiteSpace(value));
}
}
The code above generates the following result.