我有两节课。 1 个存放我的所有记录,而 1 个我只想存放我独特的字符串组合。
Public Class Records
Public Property ID As String
Public Property TNumber As String
Public Property TUnit As String
Public Property SiteName As String
Public Property FName As String
Public Property LName As String
Public Property MName As String
Public Property Suffix As String
Public Property Address1 As String
Public Property Address2 As String
Public Property City As String
Public Property State As String
Public Property PostalCode As String
Public Property Email As String
Public Property HomePhone As String
Public Property MobilePhone As String
Public Property Gender As String
Public Property HireDate As String
Public Property BirthDate As String
End Class
Private Class StringsUnique
Public Property S1 As String
Public Property S2 As String
Public Sub New(s1 As String, s2 As String)
Me.S1 = s1
Me.S2 = s2
End Sub
End Class
我想获得
TNumber
和 TUnit
的独特字符串组合并将其放入 StringsUnique
。"02547", "03"
"02547", "05"
"02547", "03"
我怎样才能完成课程以便我只得到唯一的结果“02547, 03”和“02547, 05”?
这是一个我尝试过但返回所有字符串组合的循环示例...
将 InsertCheck 调暗为布尔 = False 对于 I = 0 到 Records.Count - 1
If StringsUnique.Count <> 0 Then
For U = 0 To StringsUnique.Count - 1
If (StringsUnique.Item(U).S1 <> Records(I).TNumber.ToString And StringsUnique.Item(U).S2 <> Records(I).TUnit) Or (StringsUnique.Item(U).S1 = Records(I).TNumber.ToString And StringsUnique.Item(U).S2 <> Records(I).TUnit) Or (StringsUnique.Item(U).S1 <> Records(I).TNumber.ToString And StringsUnique.Item(U).S2 = Records(I).TUnit) Then
InsertCheck = True
End If
Next
Else
StringsUnique.Add(New StringsUnique(Records(I).TNumber.ToString, Records(I).TUnit.ToString))
End If
If InsertCheck = True Then
StringsUnique.Add(New StringsUnique(Records(I).TNumber.ToString, Recprds(I).TUnit.ToString))
End If
InsertCheck = False
Next
Dim q =(从 r 在记录中选择新的 {Key .S1 = r.TNumber,Key .S2 = r.TUnit} 不同).ToList()
Q 现在是不同字符串组合的列表!
谢谢 – GSerg