473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Exit out of Class


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.

Nov 17 '05 #1
3 15353
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
Nov 17 '05 #2
I do not quite follow what you mean by exit the class... perhaps exit the
method or function? Something like:

void MyFunc()
{
if( something )
{
// Do something
}
else
{
//Do something else and exit function
}

//Continue doing stuff
}

If so, you can simply use the return keyword to return from the function
(and pass back a reference if the function type requires a return value)), so
the above would look like:

void MyFunc()
{
if( something )
{
// Do something
}
else
{
//Do something else
return;
}

//Continue doing stuff
}

Brendan
"Mike L" 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.

Nov 17 '05 #3
Hi Cadel,

Does your statement of "Exit out of Class" mean exit the calling function?
Does the community's replies make sense to you? Please feel free to tell
us. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Alex | last post by:
I am trying to write an Exit module for the Certification server in VB.NET and I cant get the module to be recognised by the Certification MMC snap in. Its function is to capture Serial Numbers of...
42
by: WindAndWaves | last post by:
Dear All Can you tell me why you use a class module??? Thank you Nicolaas ---
6
by: orekin | last post by:
Hi There I have been trying to come to grips with Application.Run(), Application.Exit() and the Message Pump and I would really appreciate some feedback on the following questions .. There are...
4
by: Bob Day | last post by:
Using VS 2003, VB.net... I am confused about the Application.Exit method, where the help states "This method does not force the application to exit." Aside from the naming confusion, how do I...
0
by: metaperl | last post by:
A Comparison of Python Class Objects and Init Files for Program Configuration ============================================================================= Terrence Brannon bauhaus@metaperl.com...
3
by: Rudi | last post by:
Hello, following problem: At program end or release an assembly a serial device should get a final exit sequence. How can I do this? With Dispose() it's no problem, but this assembly is used...
8
by: jeddiki | last post by:
Hi, So far, last Friday, every file file I try and open and unzip with the ZipArchive class has failed. I have just used ZipArchive to create a zip file and then attempt to unzip it. Even...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.