I have the following code using the Zip
operator and Linq
to compare the first 100 characters of two strings:
Dim str1 As String = "My first string here..."
Dim str2 As String = "My FIRST string here..."
Dim areEqual As Boolean = str1.Zip(str2, Function(x1,x2) x1 = x2).Take(100).All(Function(equal) equal)
Console.WriteLine(areEqual)
How could I make the comparison case insensitive?
Maybe try using Char.ToLower()
:
Dim areEqual As Boolean = str1.Zip(str2, Function(x1, x2) Char.ToLower(x1) = Char.ToLower(x2)).Take(100).All(Function(equal) equal)