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?
Finally − The Finally block is used to execute a given set of statements, whether an exception is thrown or not thrown.
The #Region directive enables you to collapse and hide sections of code in Visual Basic files. The #Region directive lets you specify a block of code that you can expand or collapse when using the Visual Studio code editor. The ability to hide code selectively makes your files more manageable and easier to read.
Using statement basically marks a boundary for the objects specified inside using () braces. So when code block using (){} (in C#) or Using – End Using (in VB.NET) is exited either after normal execution or some exception cause, the framework invokes the Dispose method of these objects automatically.
In C#, a code block is a group of lines of code between curly braces {} . { //Everything between { and } is part of this code block. }
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With