I have a List
Public Class Connoisseur
Public Name As String
Public Pieces As String
End Class
Private Sub Button26_Click(sender As Object, e As RibbonControlEventArgs) Handles Button26.Click
Dim CS As New List(Of Connoisseur)()
End Sub
How to use generics Write an IFNotExistsAdd function
CS = {"test1","2"}
It looks like this
CS.IFNotExistsAdd(New Connoisseur() With{.Name="test1",.Pieces="1"}) 'This line will not be added because CS.Name already contains "test1"
CS.IFNotExistsAdd(New Connoisseur() With{.Name="test2",.Pieces="1"})
The output looks like this
Output:
{"test1","2"}
{"test2","1"}
You're question is not entirely clear. IFNotExistsAdd is not a valid method name for a List, so you have to create an extension method.
Create a Module (using the same namespace as the calling class)
Then you need to add an Equals override to the class (I've also added an initialiser for the properties)
You can then run add items to the list and it will only add those that are unique
This will only add test1 and test2.