VB.net Program to Demonstrate the Isnullorwhitspace() Method of String Class

You are currently viewing VB.net Program to Demonstrate the Isnullorwhitspace() Method of String Class

VB.Net program to demonstrate the IsNullorWhitSpace() method of String class

'VB.NET program to demonstrate the IsNullOrWhiteSpace() method 
'of String class.

Imports System

Module Module1
    Sub Main()
        Dim str1 As String = " "
        Dim str2 As String = "Hello World"
        Dim ret As Boolean

        ret = String.IsNullOrWhiteSpace(str1)

        If ret = True Then
            Console.WriteLine("Strings str1 contains Null or only Whitespace")
        Else
            Console.WriteLine("Strings str1 does not contain Null or only Whitespace")
        End If

        ret = String.IsNullOrWhiteSpace(str2)
        If ret = True Then
            Console.WriteLine("Strings str2 contains Null or only Whitespace")
        Else
            Console.WriteLine("Strings str2 does not contain Null or only  Whitespace")
        End If
    End Sub
End Module
Strings str1 contains Null or only Whitespace
Strings str2 does not contain Null or only  Whitespace
Press any key to continue . . .

Ranjith Kumar

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply