C#控制台应用程序在我运行后自动关闭
当我运行这个简单的应用程序时,它会无缘无故地自动关闭。如何预防 代码:C#控制台应用程序在我运行后自动关闭,c#,console-application,C#,Console Application,当我运行这个简单的应用程序时,它会无缘无故地自动关闭。如何预防 代码: 只需添加Console.ReadKey()打印值后 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApp1 { class Program { static void Mai
只需添加
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();
}
}
}
放置Console.ReadLine()代码>在结尾,我猜你的意思是,当你调试它时,它会自动关闭。在末尾添加一个Console.ReadLine()
。我已经写了答案。你需要一句谚语“按任意键继续”,这样你就可以在控制台关闭之前查看它。但仅当您在调试器中从桌面快捷方式或资源管理器运行它时。而不是当你从命令行处理器运行它的时候,控制台模式的应用程序被设计用来做什么。支持任何一种方式。谢谢回答!因为我的分数不够,所以请点击向上投票,好吗?
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();
}
}
}