Imports System
Public Class MainClass
Shared Sub Main()
Dim string1 As String = "hello"
Dim string2 As String = "good bye"
Dim string3 As String = "Happy Birthday"
Dim string4 As String = "happy birthday"
Dim output As String
Dim quotes As Char = ChrW(34)
Console.WriteLine( "output values of four Strings")
Console.WriteLine( "string1 = " & quotes & string1 & quotes & _
vbCrLf & "string2 = " & quotes & string2 & quotes & _
vbCrLf & "string3 = " & quotes & string3 & quotes & _
vbCrLf & "string4 = " & quotes & string4 & quotes)
Console.WriteLine(" test for equality using Equals method ")
If (string1.Equals("hello")) Then
Console.WriteLine( "string1 equals " & quotes & "hello" & quotes )
Else
Console.WriteLine( "string1 does not equal " & quotes & _
"hello" & quotes )
End If
Console.WriteLine( "test for equality with = ")
If string1 = "hello" Then
Console.WriteLine( "string1 equals " & quotes & "hello" & _
quotes )
Else
Console.WriteLine("string1 does not equal " & quotes & _
"hello" & quotes)
End If
Console.WriteLine(" test for equality comparing case ")
If (String.Equals(string3, string4)) Then
Console.WriteLine("string3 equals string4")
Else
Console.WriteLine("string3 does not equal string4" )
End If
Console.WriteLine(" test CompareTo")
Console.WriteLine("string1.CompareTo(string2) is " & _
string1.CompareTo(string2) & vbCrLf & _
"string2.CompareTo(string1) is " & _
string2.CompareTo(string1) & vbCrLf & _
"string1.CompareTo(string1) is " & _
string1.CompareTo(string1) & vbCrLf & _
"string3.CompareTo(string4) is " & _
string3.CompareTo(string4) & vbCrLf & _
"string4.CompareTo(string3) is " & _
string4.CompareTo(string3) )
End Sub ' Main
End Class
|