Need help with this basic Contains<>() extension method and Lambda expressions
- by Polaris878
Hi,
Say I have the following class:
class Foo
{
// ctor etc here
public string Bar
{
get;
}
}
Now, I have a LinkedList of Foos declared like so: LinkedList<Foo>
How would I write a basic Contains<() for this?
I want to be able to do this:
Foo foo = new Foo(someString);
LinkedList<Foo> list = new LinkedList<foo>();
// Populate list with Foos
bool contains = list.Contains<Foo>(foo, (x => foo.Bar == x.Bar));
Am I trying to do this correctly?
Thanks