当我运行这个简单的应用程序时,它无缘无故地关闭。如何防止?
代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
int a = 10;
int b = 20;
int c = a * b;
Console.WriteLine(c);
}
}
}
答案 0 :(得分:1)
打印值后,只需添加Console.ReadKey();
即可。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
int a = 10;
int b = 20;
int c = a * b;
Console.WriteLine(c);
Console.ReadKey();
}
}
}