generic list with contains item

S

Smokey Grindel

I have a list of items that is in the list of <T> format... and then in that
are objects I created that implement the IComparable interface... now if I
took this list and did a contains(objectThatIsAlreadyInList) would it find
it? how exactly does contains in a generic list work? is it just by object
reference or does it use the Comparable interface to check if it has an
item? thanks!
 
M

Mattias Sjögren

how exactly does contains in a generic list work? is it just by object
reference or does it use the Comparable interface to check if it has an
item?

Have another look at the documentation for List(Of T).Contains, it
actually says exactly how existance is determined. Basically it uses
IEquatable if implemented, otherwise Object.Equals.


Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top