I am using Visual studio 2015,went to projects folder>bin>debug>ConsoleApplication1 and opened it,Command prompt opened and said: type a number,any number! if i press any key the Command prompt instantly shuts down,tried deleting and coding again but no use,still shuts down,but in Visual studio when i press Ctrl + F5 everything is working.
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Type a number, any number!");
ConsoleKeyInfo keyinfo = Console.ReadKey();
PrintCalculation10times();
if (char.IsLetter(keyinfo.KeyChar))
{
Console.WriteLine("That is not a number, try again!");
}
else
{
Console.WriteLine("Did you type {0}", keyinfo.KeyChar.ToString());
}
}
static void PrintCalculation()
{
Console.WriteLine("Calculating");
}
static void PrintCalculation10times()
{
for (int counter = 0; counter <= 10; counter++)
{
PrintCalculation();
}
}
}