Is it possible to create anonymous delegates in vb.net version 8 or earlier? If so, could someone provide an example of the syntax? Thanks.
+4
A:
In VB 9.0 you can create single line lambda expressions
Dim del = Function (x) x + 42
In VB 10.0 (not yet released). You will be able to create both multiline function and sub routines (as well as single line subs). For example
Dim del = Function (x)
Return x + 42
End Funtion
EDIT OP clarified it was for pre- VB 9.0
No, there is no way prior to VB 9.0 to create lambda expressions / anonymous delegates in VB.
JaredPar
2009-04-07 20:56:40
Although it didn't answer the question, thanks for the info about VB10 anonymous delegates!
Meta-Knight
2009-04-08 04:14:24
+2
A:
Yes, but only in Visual Studio 2008/.Net 3.0 and later.
Use the Function keyword.
Joel Coehoorn
2009-04-07 20:57:32