tags:

views:

50

answers:

2

probably a trivially easy thing to do...

In C# you can introduce a block simply by putting in { }

eg. if you wanted to do a lambda like x => { var x="x"; var y="y"; }

so is there a way to introduce a scope / block in VB.NET?

+4  A: 

Yes it's possible to introduce arbitrary blocks into VB.Net

If True Then
  ...
End If

In Visual Studio 2008 though you cannot do this for lambda expressions. Vb.Net only supports single expression lambdas in Visual Studio 2008. Statement lambdas were not added until Visual Studio 2010. There is no way to get that style of block functionality into an expression lambda using 2008 constructs.

JaredPar
A: 

Just found you can use : to chain multiple statements onto the same line, and with at the end of the line _ you can chain that across multiple lines. Not sure if that works in a lambda or not.

Still, not an arbitrary block of code

Keith Nicholas
The ':' won't work in lambdas because it's used to combine statements. A lambda in 2008 can only contain expressions
JaredPar