Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Measuring LINQ Any operator
var useAny = false;
var loremipsum = @"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo
ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes,
nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem.
Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget,
arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu
pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean
vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac,
enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a,";
var items = loremipsum.Split(new [] {' '}).Distinct().ToList();
var lookfor = "pede";
var runPerf =new Action( () => {
if (!useAny)
{
foreach (var item in items)
{
if (item == lookfor) {
return;
}
}
}
else
{
items.Any (i => i == lookfor);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.