Obtaining Counts Using Enumerable
Using these query operators (and auxiliary members of the System.Linq.Enumerable type), you
are able to build very expressive query expressions in a strongly typed manner. To invoke the
Enumerable extension methods, you typically wrap the LINQ expression within parentheses to cast
the result to an IEnumerable-compatible object to invoke the Enumerable extension method.
You have already done so during our examination of immediate execution; however, here is
another example that allows you to discover the number of items returned by a LINQ query:
static void GetCount()
{
string[] currentVideoGames = {"Morrowind", "BioShock",
"Half Life 2: Episode 1", "The Darkness",
"Daxter", "System Shock 2"};
Do'stlaringiz bilan baham: |