Suppose you have a collection of Foo classes:
class Foo { public string Bar; public string Baz; } List<Foo> foolist;
And you want to check this collection to see if another record matches Bar .
bool isDuplicate = false; foreach (Foo f in foolist) { if (f.Bar == SomeBar) { isDuplicate = true; break; } }
Contains() does not work because it compares classes as integers.
Is there anyone better way to do this that works for .NET 2.0?
source share