StringExtensions.IsEmpty Method
Checks whether a string value is null reference (Nothing in Visual Basic) or empty.
Namespace: System.Web.WebPages
Assembly: System.Web.WebPages (in System.Web.WebPages.dll)
Syntax
'Declaration
<ExtensionAttribute> _
Public Shared Function IsEmpty ( _
value As String _
) As Boolean
'Usage
Dim value As String
Dim returnValue As Boolean
returnValue = value.IsEmpty()
public static bool IsEmpty(
this string value
)
[ExtensionAttribute]
public:
static bool IsEmpty(
String^ value
)
static member IsEmpty :
value:string -> bool
public static function IsEmpty(
value : String
) : boolean
Parameters
- value
Type: System.String
The string value to test.
Return Value
Type: System.Boolean
true if value is null reference (Nothing in Visual Basic) or is a zero-length string (""); otherwise, false.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type String. When you use instance method syntax to call this method, omit the first parameter. For more information, see https://msdn.microsoft.com/en-us/library/bb384936(v=vs.111) or https://msdn.microsoft.com/en-us/library/bb383977(v=vs.111).
Remarks
The IsEmpty method can be helpful when you want to use a method in the StringExtensions class to convert a string to another data type. If you call the IsEmpty method to check a string before converting it, you can determine whether the string is empty and the code can take appropriate action, such as prompting a user to provide a value.