Click to See Complete Forum and Search --> : What is the code to make this in C#?


aprilzoom
February 19th, 2010, 02:24 PM
I am trying to do an console application. This application allows to user to prompt an input until user prompt the negative numbers. However, after an user typed a number, it terminates automatically. I want that the amount of value can be typed in the application in second time or third time until negative numbers. What is the code to make this in C#?
Kindest Regards

memeloo
February 19th, 2010, 02:37 PM
have you tried the while loop ?

aprilzoom
February 19th, 2010, 02:40 PM
I tried while, for loops and also if statment. But, all don't work.

memeloo
February 19th, 2010, 02:54 PM
from the information that you share I suggest you write if(9 == -7) return +8....

can post some code, I don't feel like writing it from scrach today.

rliq
February 21st, 2010, 11:59 PM
Have you tried a for loop and an if statement together?

Otherwise, as a last resort may I suggest.

using (HelpFile doc = new HelpFile())
{
doc.Read();
}

rliq
February 22nd, 2010, 12:05 AM
Seriously, here's some pseudo code....


while (true)
{
// read some input from the keyboard
// if it is a negative number then
// break (out of loop)
}

nelo
February 22nd, 2010, 03:16 AM
I tried while, for loops and also if statment. But, all don't work.

A few suggestions...

1. Try and post the code that you've got so far. It would make it easier for others to help you.

2. Try and give us some indication of your background and ability/experience.

To me it seems like you don't understand the nature of Console applications. Basically you have to keep reading for input from the user. Once you stop reading input then your program executes and terminates. Here's a link to get you started...Console.ReadLine (http://msdn.microsoft.com/en-us/library/system.console.readline.aspx)