Question : How to compare two string

Hi,
How to compare two string and display the difference.Example
string1 : abc
string2: abg
Result:1 letter is different

Cheers

Answer : How to compare two string

this is a sample code


Dim s1 As String = "abc"
Dim s2 As String = "abgc"
Dim diffcnt As Integer = 0
For Each c As Char In s1
    If Not s2.Contains(c) Then
        diffcnt = diffcnt + 1
    End If
Next
For Each c As Char In s2
    If Not s1.Contains(c) Then
        diffcnt = diffcnt + 1
    End If
Next
Response.Write(diffcnt & " letter(s) is different")
Random Solutions  
 
programming4us programming4us