Another conversion question... break in C# to vb

  • Thread starter Thread starter Brian Henry
  • Start date Start date
B

Brian Henry

How would you convert a scope break statement to vb?

ex:

if (buff[0] == '\n')
{
break;
}
 
Hi Brian,

break does not break out of an if statement, so from the code snippet you
posted, it has no actual context. break in C# breaks out of a loop construct or
a switch statement. For a switch statement (Select Case in VB) you don't need
the break statement in VB, it is assumed. For loop constructs, break would be
the equivalent of Exit Do, Exit For or Exit While.
 
LOL ! There is no such thing, and given that VB's Select Case does not have
fall through there is no need to in a select Case statement.

(Note: C# does not have fall through in a switch statement either, but still
requires the break statement in a switch block due to some weird consistency
with Java or other C style languages that do have fall through)



John Smith said:
use
Exit Select

Brian said:
How would you convert a scope break statement to vb?

ex:

if (buff[0] == '\n')
{
break;
}
 
Before you fall and hurt yourself laughing - there actually is an
"Exit Select" in VB.NET.
 
ROFL ! Just to be clear though, that is not needed in Vb.NET as per the usual
use of C#'s break in a switch statement. It would be only when C# used multiple
break statements inside a case block. The Exit Select would be the equivalent of
the break statements except the last break statement per case block in a switch
block.
 
Back
Top