6 ways to check for String Equality in VB.Net
Imports System.Text
Private str1 As String
Private str2 As String
Private str3 As String
Private pos1 As Boolean
Private pos2 As Integer
- pos1 = str1 = str2
- pos1 = String.Equals(str1, str2)
- pos2 = String.Compare(str1, str2)
str3 = If(pos2 = 0, "True", "False")
- pos2 = String.CompareOrdinal(str1, str2)
str3 = If(pos2 = 0, "True", "False")
- pos2 = str1.CompareTo(str2)
str3 = If(pos2 = 0, "True", "False")
- pos2 = StrComp(str1, str2)
str3 = If(pos2 = 0, "True", "False")