C# LINQ — “Any”
LINQ (Language-Integrated Query) is a set of integrated C# capabilities which allow queries against data.
Today’s Objective: Go over the LINQ Any function used to search a data collection for a specific value/s.
The LINQ Any Method:
Similar to the Contains function, the Any function allows for the searching of a data collection for the existence of a specific data value or condition, returning a boolean if it exists.
As shown in the example above, using LINQ Any is one way to simplify your C# code and minimize your line count.
Note: “name” can be called whatever you want, just like “nameFound”. Since mine is a string of names, “name” is an appropriate variable name.