Determines whether the specified string is null or an empty string ("").
The string to test.
true if the value parameter is null or an empty string (""); otherwise, false.
This method is equivalent to calling (value == null || value.Length == 0).
It is often used to validate user input or to perform operations only on non-empty strings.
string str1 = null;
string str2 = "";
string str3 = "Hello";
bool isNullOrEmpty1 = String.IsNullOrEmpty(str1); // true
bool isNullOrEmpty2 = String.IsNullOrEmpty(str2); // true
bool isNullOrEmpty3 = String.IsNullOrEmpty(str3); // false
Console.WriteLine($"str1 is null or empty: {isNullOrEmpty1}");
Console.WriteLine($"str2 is null or empty: {isNullOrEmpty2}");
Console.WriteLine($"str3 is null or empty: {isNullOrEmpty3}");
Dim str1 As String = Nothing
Dim str2 As String = String.Empty
Dim str3 As String = "Hello"
Dim isNullOrEmpty1 As Boolean = String.IsNullOrEmpty(str1) ' True
Dim isNullOrEmpty2 As Boolean = String.IsNullOrEmpty(str2) ' True
Dim isNullOrEmpty3 As Boolean = String.IsNullOrEmpty(str3) ' False
Console.WriteLine($"str1 is null or empty: {isNullOrEmpty1}")
Console.WriteLine($"str2 is null or empty: {isNullOrEmpty2}")
Console.WriteLine($"str3 is null or empty: {isNullOrEmpty3}")