Suppose you have a collection of classes:
class Foo
{
public string Bar;
public string Baz;
}
List<Foo> foolist;
And you want to check this collection to see if another entry has a matching Bar.
bool isDuplicate = false;
foreach (Foo f in foolist)
{
if (f.Bar == SomeBar)
{
isDuplicate = true;
break;
}
}
Contains() doesn't work because it compares the classes as whole.
Does anyone have a better way to do this (That works for .NET 2.0).