Need help with this basic Contains<>() extension method and Lambda expressions
Posted
by Polaris878
on Stack Overflow
See other posts from Stack Overflow
or by Polaris878
Published on 2010-04-02T20:01:42Z
Indexed on
2010/04/02
20:13 UTC
Read the original article
Hit count: 244
Hi,
Say I have the following class:
class Foo
{
// ctor etc here
public string Bar
{
get;
}
}
Now, I have a LinkedList
of Foo
s 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
© Stack Overflow or respective owner