学C#第一个控制台程序,怎么一闪就退出了,看不到结果?
using System;
using System.Collections.Generic;
using System.Text;
namespace Addition
{
class Program
{
static void Main(string[] args)
{
string FirstNumber,
SecondNumber;
int number1,
number2,
sum;
Console.Write( "Please enter the first integer: ");
FirstNumber = Console.ReadLine();
Console.Write( "Please enter the second integer: ");
SecondNumber = Console.ReadLine();
number1 = Int32.Parse(FirstNumber);
number2 = Int32.Parse(SecondNumber);
sum = number1 + number2;
Console.WriteLine( "\n the sum is {0}. ",sum);
}
}
}
我运行程序,提示输入,输完二个数(假设50,70),就一闪而过退出了,根本看不到结果。按照书上的提示,应该有下面的提示:
the sum is 120.
为什么我看不到?请教!
------解决方案--------------------最后面在加个
Console.ReadLine();
------解决方案--------------------按Ctrl+F5
------解决方案--------------------控制台程序,就是在控制台下面执行的。
如果想停顿,就 在后面加
Console.Read();
------解决方案--------------------using System;
using System.Collections.Generic;
using System.Text;
namespace Addition
{
class Program
{
static void Main(string[] args)
{
string FirstNumber,
SecondNumber;
int number1,
number2,
sum;
Console.Write( "Please enter the first integer: ");
FirstNumber = Console.ReadLine();
Console.Write( "Please enter the second integer: ");
SecondNumber = Console.ReadLine();
number1 = Int32.Parse(FirstNumber);