String.IsNullOrEmpty Method
Silverlight
Updated: January 2011
Indicates whether the specified string is Nothing or an Empty string.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Parameters
- value
- Type: System.String
The string to test.
Return Value
Type: System.Booleantrue if the value parameter is Nothing or an empty string (""); otherwise, false.
The following code example determines whether each of three strings has a value, is an empty string or is Nothing.
Class Example Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock) Dim s1 As String = "abcd" Dim s2 As String = "" Dim s3 As String = Nothing outputBlock.Text += String.Format("String s1 {0}.", Test(s1)) & vbCrLf outputBlock.Text += String.Format("String s2 {0}.", Test(s2)) & vbCrLf outputBlock.Text += String.Format("String s3 {0}.", Test(s3)) & vbCrLf End Sub Public Shared Function Test(ByVal s As String) As String If String.IsNullOrEmpty(s) Then Return "is null or empty" Else Return String.Format("(""{0}"") is not null or empty", s) End If End Function End Class ' The example displays the following output: ' String s1 ("abcd") is not null or empty. ' String s2 is null or empty. ' String s3 is null or empty.
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.