Mike L <Ca***@nospam.nospam> wrote:
What is the code to exit (break) out of a class?
I have a class, with an if statement, if is true then exit class, if false
continue with the code in the class.
A bit of terminology first - a class doesn't have an "if" statement, a
method does.
However, it sounds like you're basically after a return statement:
if (whatever)
{
return;
}
Note that if the method has a non-void return type, you'll have to
specify which value you want to return.
Alternatively (depending on the situation) you may want to throw an
exception instead. Is your condition an error condition of some kind,
or is it normal behaviour?
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog:
http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too