Lambda Expressions: Func Delegates
Sun, Oct 11 2009 16:49
A Func delegate encapsulates a method that returns a value. It takes up to four parameters (and this number is increased in .NET 4.0) plus the return value.
[To begin with an overview of lambda expressions, start here.]
The following signature is a Func delegate that takes two integer parameters and returns a string.
Func<int, int, string>
Func(Of Integer, Integer, String)
There are many examples of Func delegates.
The following code demonstrates the Sum function that sums the sales total for all customers in the list (and assumes that a Customer object has a SalesTotal property).
var total = custList.Sum(c =>
Dim total = custList.Sum(Function(c) _