Extract item in a list if Contains returns true

Posted by Matt on Stack Overflow See other posts from Stack Overflow or by Matt
Published on 2010-04-23T06:05:05Z Indexed on 2010/04/23 6:13 UTC
Read the original article Hit count: 403

Filed under:
|
|

I have two lists A and B, at the beginning of my program, they are both filled with information from a database (List A = List B). My program runs, List A is used and modified, List B is left alone. After a while I reload List B with new information from the database, and then do a check with that against List A.

foreach (CPlayer player in ListA)
      if (ListB.Contains(player))
            -----

Firstly, the object player is created from a class, its main identifier is player.Name. If the Name is the same, but the other variables are different, would the .Contains still return true?

Class CPlayer(
      public CPlayer (string name)
              _Name = name

At the ---- I need to use the item from ListB that causes the .Contains to return true, how do I do that?

© Stack Overflow or respective owner

Related posts about c#

Related posts about contains