Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In VB.NET can you do an arbitary code block?

Tags:

vb.net

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?

like image 719
Keith Nicholas Avatar asked Oct 08 '09 21:10

Keith Nicholas


People also ask

Which of the following block of VB net is used to execute?

Finally − The Finally block is used to execute a given set of statements, whether an exception is thrown or not thrown.

How to hide part of code in Visual Studio code?

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.

What is Using statement in vb net?

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.

What is code block in C#?

In C#, a code block is a group of lines of code between curly braces {} . { //Everything between { and } is part of this code block. }


1 Answers

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.

like image 156
JaredPar Avatar answered Sep 26 '22 14:09

JaredPar