セミコロンとったらVB.NETとかとかとか、世迷言だよ、ぐるるる。
とあるクラス、リストしてから、重複除いた要素でごにょりたい、で作ったのでメモ。
Module Module2
Sub Main()
Dim samples As New List(Of KeyData)
Dim rnd As New Random
Dim KeysCount = rnd.Next(1, 120)
Console.WriteLine("{0} 件キー", KeysCount)
For x As Integer = 1 To KeysCount
samples.Add(New KeyData With {
.Key1 = rnd.Next(1, 3).ToString("KeyA-000"),
.Key2 = rnd.Next(1, 3).ToString("KeyB-000"),
.Key3 = rnd.Next(1, 3).ToString("KeyC-000")
})
Next
Console.WriteLine("件数 : {0}", samples.Count)
Console.WriteLine("重複なし件数 : {0}", samples.Distinct.Count)
Console.ReadKey()
End Sub
End Module
Public Class KeyData
Implements IEquatable(Of KeyData)
Property Key1 As String
Property Key2 As String
Property Key3 As String
Public Function Equals1(other As KeyData) As Boolean Implements IEquatable(Of KeyData).Equals
Return Key1 = other.Key1 _
AndAlso Key2 = other.Key2 _
AndAlso Key3 = other.Key3
End Function
Public Overrides Function GetHashCode() As Integer
Return Key1.GetHashCode Xor Key2.GetHashCode Xor Key3.GetHashCode
End Function
End Class
結果、こうなったんで、OK。