iequalitycomparer

  • Thread starter Thread starter parez
  • Start date Start date
P

parez

Hi all,

I have a custom colllelctoin class which inherits collecton base.
It is a collecton of objects of type X and X has ID integer as like a
unique key.


How do i check if the object already exists in the collection?.


I think i am missing something straightfoward.


Thanks for your input.
 
Contains or IndexOf methods should work. Note that those methods use
X's Equals method to perform search.

If the Equals method of X is inadequate (and you could not modify/add
it), you could make a helper method for that purpose using the foreach
loop.
 

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

Back
Top