473,382 Members | 1,692 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

generic list with contains item

I have a list of items that is in the list of <Tformat... 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!
Mar 21 '07 #1
2 1403
whoops not ICompare, I mean IEquatable no wonder it wasnt working..

"Smokey Grindel" <no****@nospam.comwrote in message
news:eQ**************@TK2MSFTNGP06.phx.gbl...
>I have a list of items that is in the list of <Tformat... 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!

Mar 21 '07 #2
>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

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Mar 21 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Harold Howe | last post by:
Howdy all, I am getting a compiler error regarding a consrained conversion. It complains that it can't make the type conversion, even though the generic type argument inherits from the target of...
4
by: Adam Clauss | last post by:
I ran into a problem a while back when attempting to convert existing .NET 1.1 based code to .NET 2.0 using Generic collections rather than Hashtable, ArrayList, etc. I ran into an issue because...
7
by: =?Utf-8?B?Sm9lbCBNZXJr?= | last post by:
I have created a custom class with both value type members and reference type members. I then have another custom class which inherits from a generic list of my first class. This custom listneeds...
4
by: Bill McCormick | last post by:
Hello, I have a list of struct's that have generic fields: public struct Item<T1, T2: IComparable<Item<T1, T2>{ private T1 _t1; private T2 _t2; public T1 t1 { get { return _t1; }
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.