how to break out of "if" block in VB.NET

In VB.net:

if i > 0 then
   do stuff here!
end if

In C#:

if (i > 0)
{
  do stuff here!
}

You can't 'break out' of an if statement. If you are attempting this, your logic is wrong and you are approaching it from the wrong angle.

An example of what you are trying to achieve would help clarify, but I suspect you are structuring it incorrectly.


There isn't such an equivalent but you should't really need to with an If statement. You might want to look into using Select Case (VB) or Switch (C#) statements.


In C# .NET:

if (x > y) 
{
    if (x > z) 
    {
        return;
    }

    Console.Writeline("cool");
}

Or you could use the goto statement.

Tags:

Asp.Net

Break