1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| Public Class Test
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim tab As New List(Of objTest)
Dim obj1 As New objTest()
obj1.nom = "nom1"
obj1.prenom = "prenom1"
Dim obj2 As New objTest()
obj2.nom = "nom1"
obj2.prenom = "prenom1"
Dim obj3 As New objTest()
obj3.nom = "nom2"
obj3.prenom = "prenom2"
Dim obj4 As New objTest()
obj4.nom = "nom2"
obj4.prenom = "prenom2"
tab.Add(obj1)
tab.Add(obj2)
tab.Add(obj3)
tab.Add(obj4)
Dim tst As IEnumerable(Of objTest) = (From s In tab _
Select New objTest With { _
.nom = s.nom, _
.prenom = s.prenom}).Distinct().ToList()
Console.ReadLine()
End Sub
Class objTest
Private _nom As String
Property nom() As String
Get
Return _nom
End Get
Set(ByVal value As String)
_nom = value
End Set
End Property
Private _prenom As String
Property prenom() As String
Get
Return _prenom
End Get
Set(ByVal value As String)
_prenom = value
End Set
End Property
End Class
End Class |
Partager