If you are (or hope to be) a .NET developer, knowing LINQ is a huge time-saver. It’s a syntax that allows you to manipulate data in a fashion that’ll be familiar to anyone who’s worked in a database.
Any
One of the many nice functions in LINQ is a single word that iterates through a collection, returning true
if at least one item in the collection matches the condition you specify.
|
|
But what’s the opposite of Any<T>()
?
What if, instead of finding out whether the list of currencies includes “peso”, you wanted to make sure the list of currencies did not include “peso”? You could negate the above, but you might think that reads a bit funny… and I’d agree.
|
|
All
The only way to make sure that a list doesn’t include a particular value, or that no item in the collection matches a particular condition, is to check every single item in the collection… and that’s what All<T>()
is for.
|
|