Function keepOnlyDuplicates(ByRef list1 As List(Of Integer), ByRef list2 As List(Of Integer)) As List(Of Integer)
Dim returnList As New List(Of Integer)
For Each i As Integer In list1
For Each j As Integer In list2
If i = j Then
returnList.Add(i)
Exit For
End If
Next
Next
Return returnList
End Function
この関数を作成して、他の2つの整数から、両方にある整数のみを含む整数の新しいリストを作成しました(個々のリストには重複がありません)。
この関数を変更して、任意のタイプのリストを受け入れ、それに応じたタイプのリストを問題なく返す方法はありますか? 本当に複雑な場合は、他のタイプの別の関数を簡単に作成できます。しかし、どのタイプを呼び出すかだけの問題である場合、どうすればそれを行うことができますか?
ありがとう。