Monday, July 16, 2007

 

Added Lambda Functions to VB.NET 9.0 in June 2007 CTP

Starting from the June 2007 CTP release even Visual Basic language has its own way to manage Lambda expressions. Let's see an example:

1: Public Delegate Function Sum(ByVal a As Integer, ByVal b As Integer) As Integer
2: ...
3: Dim DoSum As Sum = Function(ByVal a, ByVal b) a + b
4: Dim ret As Integer = DoSum(4, 5)
5:
6: 'Using named arguments
7: ret = DoSum(b:=3, a:=4)

Using the Function keyword you can define the Lambda expression (see row 3). In the next beta 2 release will not be more needed to specify the ByVal keyword for the Lambda's parameters.

Thanks to Corrado Cavalli for this info.

Labels: , ,


Comments: Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?