Dim BeforeValue AS String = "123456789"
Dim AfterValue AS String = "321465798"
'用List储存差异下标,两者比对的值
Dim differences As New List(Of (Index As Integer, Before As Char, After As Char))()
For i As Integer = 0 To BeforeValue.Length - 1
If BeforeValue(i) <> AfterValue(i) Then
differences.Add((Index:=i, Before:=BeforeValue(i), After:=AfterValue(i)))
End If
Next
'当有BeforeValue ,AfterValue 有差异时可循环拿到对应下标和值
If differences.Count > 0 Then
For Each diff In differences
Dim diffIndex As Integer = diff.Index
Dim diffBefore As String = diff.Before
Dim diffAfter As String = diff.After
Next
End If
标签:Dim,储存,differences,String,C#,AfterValue,BeforeValue,字符串,diff
From: https://www.cnblogs.com/sumu80/p/17984693