List
List
// Query #4.
double average = numbers1.Average();
// Query #5.
IEnumerable
If the method has parameters, these are provided in the form of a lambda expression, as shown in the following example:
// Query #6.
IEnumerable
In the previous queries, only Query #4 executes immediately. This is because it returns a single value, and not a generic IEnumerable<(Of <(T>)>) collection. The method itself has to use foreach in order to compute its value.
Each of the previous queries can be written by using implicit typing with var, as shown in the following example:
// var is used for convenience in these queries
var average = numbers1.Average();
var concatenationQuery = numbers1.Concat(numbers2);
var largeNumbersQuery = numbers2.Where(c => c > 15);
No comments:
Post a Comment