I am implementing an application, in which you have to validate if some object is in a list. This happens with .contains I know, but I fill up my list with an XML file, and then the object which I check if the list contains this, is newly created so the references are not the same and .Contains will always be false.
Someone who knows to fix this problem? This is the code:
if (qfs.Contains(exa.Question.File))
{
booleansQuestionFile[i] = true;
}
The if statement is always false.
As described in the documentation,
Containsuses the default equality comparer. To change the default behavior, make your class implementIEquatable<T>or overrideEquals.