I work with a code base where lists often need to be searched for a single item.
Is it faster to use Predicate and Find () than manually enumerate in a list?
eg:
string needle = "example";
FooObj result = _list.Find(delegate(FooObj foo) {
return foo.Name == needle;
});
vs.
string needle = "example";
foreach (FooObj foo in _list)
{
if (foo.Name == needle)
return foo;
}
While they are equivalent in functionality, are they equivalent in performance?
source
share