473,382 Members | 1,258 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,382 software developers and data experts.

How do I exit the program?

(1) What code should I put in case 'e':?
(2) Should I still put default case?
do
{
Console.Write("Enter a selection from the following
list:\n" +
"a. Display ...................\n" +
"b. Display ....................\n." +
"c. Display ................\n.." +
"e. Exit this program\n");
ch = Char.Parse(Console.ReadLine());
Console.WriteLine("");
switch (ch)
{

case 'e':
????????

} // end switch
} while ( ch== etc.)

Oct 9 '06 #1
6 1619

Uzytkownik "Amanda" <am**********@yahoo.comnapisal w wiadomosci
news:11**********************@k70g2000cwa.googlegr oups.com...
(1) What code should I put in case 'e':?
(2) Should I still put default case?
do
{
Console.Write("Enter a selection from the following
list:\n" +
"a. Display ...................\n" +
"b. Display ....................\n." +
"c. Display ................\n.." +
"e. Exit this program\n");
ch = Char.Parse(Console.ReadLine());
Console.WriteLine("");
switch (ch)
{

case 'e':
????????

} // end switch
} while ( ch== etc.)
Try this one. Add reference System.Windows.Forms in to your project and then
you can use Application.Exit()

Forrest
Oct 9 '06 #2

Forrest wrote:
Uzytkownik "Amanda" <am**********@yahoo.comnapisal w wiadomosci
news:11**********************@k70g2000cwa.googlegr oups.com...
(1) What code should I put in case 'e':?
[..]

Try this one. Add reference System.Windows.Forms in to your project and then
you can use Application.Exit()
This is Console application as required by sample exe file given.

>
Forrest
Oct 9 '06 #3

Uzytkownik "Amanda" <am**********@yahoo.comnapisal w wiadomosci
news:11**********************@k70g2000cwa.googlegr oups.com...
>
Forrest wrote:
>Uzytkownik "Amanda" <am**********@yahoo.comnapisal w wiadomosci
news:11**********************@k70g2000cwa.googleg roups.com...
(1) What code should I put in case 'e':?
[..]
>

Try this one. Add reference System.Windows.Forms in to your project and
then
you can use Application.Exit()

This is Console application as required by sample exe file given.

>>
Forrest
Ok, maybe try this one
Environment.Exit(0);

Forrest
Oct 9 '06 #4

"Amanda" <am**********@yahoo.comwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
(1) What code should I put in case 'e':?
(2) Should I still put default case?
do
{
Console.Write("Enter a selection from the following
list:\n" +
"a. Display ...................\n" +
"b. Display ....................\n." +
"c. Display ................\n.." +
"e. Exit this program\n");
ch = Char.Parse(Console.ReadLine());
Console.WriteLine("");
switch (ch)
{

case 'e':
????????

} // end switch
} while ( ch== etc.)
Enviroment.Exit(int n);

n is errorcode returned to os.
Oct 9 '06 #5
(1):
return;

or

break;

depending on the context of the loop.

or {} and then in the contidition: ch != 'e';

(2):
Maybe prompt some error message;
what does the sample exe do?

"Amanda" <am**********@yahoo.comschrieb im Newsbeitrag
news:11**********************@k70g2000cwa.googlegr oups.com...
(1) What code should I put in case 'e':?
(2) Should I still put default case?
do
{
Console.Write("Enter a selection from the following
list:\n" +
"a. Display ...................\n" +
"b. Display ....................\n." +
"c. Display ................\n.." +
"e. Exit this program\n");
ch = Char.Parse(Console.ReadLine());
Console.WriteLine("");
switch (ch)
{

case 'e':
????????

} // end switch
} while ( ch== etc.)

Oct 9 '06 #6

Christof Nordiek wrote:
(1):
return;

or

break;

depending on the context of the loop.
I tried break before my initial post - it didn't work - but return
does. Thnaks.
>
or {} and then in the contidition: ch != 'e';

(2):
Maybe prompt some error message;
what does the sample exe do?
It says "Press any key to continue..."
>
"Amanda" <am**********@yahoo.comschrieb im Newsbeitrag
news:11**********************@k70g2000cwa.googlegr oups.com...
(1) What code should I put in case 'e':?
(2) Should I still put default case?
do
{
Console.Write("Enter a selection from the following
list:\n" +
"a. Display ...................\n" +
"b. Display ....................\n." +
"c. Display ................\n.." +
"e. Exit this program\n");
ch = Char.Parse(Console.ReadLine());
Console.WriteLine("");
switch (ch)
{

case 'e':
????????

} // end switch
} while ( ch== etc.)
Oct 9 '06 #7

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

Similar topics

10
by: JKop | last post by:
An excerpt from the Standard: 4 Calling the function void exit(int); declared in <cstdlib> (18.3) terminates the program without leaving the current block and hence without destroying any...
32
by: Protoman | last post by:
I have a function that calculates the mean of the some numbers; I need it to accept any number of parameters (one needs to be the number of the other parameters) Can you help me out here? Here's...
11
by: Yasaswi Pulavarti | last post by:
I know there are some sample user exit programs in sqllib/samples/c directory. How do I tell DB2, which user exit program to use? I know I have to edit and compile the c based user exit programs,...
0
by: szehau | last post by:
Hi all, I have a program written in C with embeded SQL. Following are the configuration: DB2/LINUX 8.1.5 Thread model: posix gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7) My problems...
5
by: QQ | last post by:
I know there are many functions that I can exit the program such as return 0, exit(0), exit(1),_EXIT(0) .... What are the difference between them? Thanks a lot!
17
by: jwaixs | last post by:
Hello, I was wondering, what's the difference between exit and return in the main() function? For me they both look the same, or aren't they? And if they aren't, which should I use in which...
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...
11
by: =?Utf-8?B?U3RldmVEQjE=?= | last post by:
Hi all. I'm using VS 2008 Express C++. I created a console application back in 1999, and updated it for VC++ 6.0 in 2001. I've updated again this past month, and have found enough differences...
39
by: mathieu | last post by:
Hi there, I am trying to reuse a piece of code that was designed as an application. The code is covered with 'exit' calls. I would like to reuse it as a library. For that I renamed the 'main'...
5
by: lemlimlee | last post by:
hello, this is the task i need to do: For this task, you are to develop a Java program that allows a user to search or sort an array of numbers using an algorithm that the user chooses. The...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.