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


Kirtan PatelRank #292 · 8.6K reputationPosted Feb 19, 2010, 9:45 PM EST
" I want that the amount of value can be typed in the application in second time or third time until negative"
april zoom3 reputationPosted Feb 19, 2010, 9:53 PM EST
Kirtan PatelRank #292 · 8.6K reputationPosted Feb 19, 2010, 9:57 PM EST
just tell me what do you want to do and what result you need .and how you want to input in strait forward way ..instead of programmatic way..
l
kiran kumarRank #3,110 · 461 reputationPosted Feb 19, 2010, 10:00 PM EST
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace myfirst
{
class Program
{
static void Main(string[] args)
{
int n;
while (true)
{
n = int.Parse(Console.ReadLine());
if (n < 0)
{
Console.WriteLine("you typed negative no bubbye");
System.Environment.Exit(1);
}
else
{
Console.WriteLine("you enterd a positive no:" + n + "");
}
}
}
}
}
MARK THE ANSWER IF IT HELPS YOU
Faruk5 reputationPosted Feb 19, 2010, 10:05 PM EST
Also you can use this code;
int Number = 0;
while (Number.ToString() != null)
{
try
{
Number = Int32.Parse(Console.ReadLine());
}
catch
{
Console.WriteLine("You should've input a number!");
}
Console.WriteLine(String.Format("Your number is {0}", Number.ToString()));
}
Shaik Ali99 reputationPosted Feb 23, 2010, 7:33 AM EST
int iInput=0;
do
{
iInput=Int32.Parse(Console.ReadLine(iInput));
}while(iInput>0)