String.IsNullOrEmpty Method (String)
Indicates whether the specified string is null or an Empty string.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- value
-
Type:
System.String
The string to test.
Return Value
Type: System.Booleantrue if the value parameter is null or an empty string (""); otherwise, false.
IsNullOrEmpty is a convenience method that enables you to simultaneously test whether a String is null or its value is Empty. It is equivalent to the following code:
You can use the IsNullOrWhiteSpace method to test whether a string is null, its value is String.Empty, or it consists only of white-space characters.
A string is null if it has not been assigned a value (in C++ and Visual Basic) or if has explicitly been assigned a value of null. Although the composite formatting feature can gracefully handle a null string, as the following example shows, attempting to call one if its members throws a NullReferenceException.
Available since 8
.NET Framework
Available since 2.0
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1