> I have a function which return a List, and I'm trying to add users to
> it from 3 different roles, but I don't want duplicate user names. The
[quoted text clipped - 22 lines]
> ---------------------
> Why doesn't the Contains work?
Hi,
Check out this link : http://expressdotnet.freehostia.com
Omar Abid
> I have a function which return a List, and I'm trying to add users to
> it from 3 different roles, but I don't want duplicate user names. The
[quoted text clipped - 22 lines]
> ---------------------
> Why doesn't the Contains work?
The Contains method works just fine, it just doesn't work the way that
you expected it to work.
The Contains method, when used on a List of reference types, checks if a
reference to the object exists in the list. As you create a new instance
of the TroubleTicketUser class, it's not the same object as the one that
exists in the list, eventhough they contain the same data.
What you want to do is to use a Dictionary(Of String, TroubleTicketUser)
where you use the user name as key.

Signature
Göran Andersson
_____
http://www.guffa.com
Larry Bud - 31 Jul 2007 14:10 GMT
On Jul 31, 5:56 am, G?ran Andersson <gu...@guffa.com> wrote:
> > I have a function which return a List, and I'm trying to add users to
> > it from 3 different roles, but I don't want duplicate user names. The
[quoted text clipped - 33 lines]
> What you want to do is to use a Dictionary(Of String, TroubleTicketUser)
> where you use the user name as key.
Ok, I get it. However, from what I see, I can't sort a Dictionary.
Göran Andersson - 31 Jul 2007 21:36 GMT
>>> I have a function which return a List, and I'm trying to add users to
>>> it from 3 different roles, but I don't want duplicate user names. The
[quoted text clipped - 28 lines]
>
> Ok, I get it. However, from what I see, I can't sort a Dictionary.
That is correct. You have to use an Array, a List or a SortedList for
that (or perhaps there are some more collections that can be sorted).
If you use a SortedList for example, you just have to loop through the
Values of the dictionary and add them to the list.

Signature
Göran Andersson
_____
http://www.guffa.com