如何阻止C#生成的.exe文件运行后自动关闭
我是C#新手,刚开始学着写程序,照着写了这么段程序:usingSystem;classWelcome{staticvoidMain(){Console.WriteLine...
我是C#新手,刚开始学着写程序,照着写了这么段程序:
using System;
class Welcome
{
static void Main()
{
Console.WriteLine("Please enter your name:");
string name1 = Console.ReadLine();
string name2 = Console.ReadLine();
Console.Write("Welcome to you ,{0} and {1}!",name1,name2);
}
}
编译生成.exe文件,然后双击.exe文件运行,应该显示:
Please enter your name:
a
b
Welcome to you,a and b!
可是,输完b之后,按回车,最后一句还看不见,窗口就一闪关闭了,我想让它四行都显示了之后然后再按任意键退出,该怎么实现?望高手指教 展开
using System;
class Welcome
{
static void Main()
{
Console.WriteLine("Please enter your name:");
string name1 = Console.ReadLine();
string name2 = Console.ReadLine();
Console.Write("Welcome to you ,{0} and {1}!",name1,name2);
}
}
编译生成.exe文件,然后双击.exe文件运行,应该显示:
Please enter your name:
a
b
Welcome to you,a and b!
可是,输完b之后,按回车,最后一句还看不见,窗口就一闪关闭了,我想让它四行都显示了之后然后再按任意键退出,该怎么实现?望高手指教 展开
3个回答
展开全部
using System;
namespace ConsoleApplication2 {
class Program {
static void Main(string[] args) {
Console.WriteLine("Please enter your name:");
string name1 = Console.ReadLine();
string name2 = Console.ReadLine();
Console.Write("Welcome to you ,{0} and {1}!", name1, name2);
//加一行读取...
Console.ReadLine();
}
}
}
namespace ConsoleApplication2 {
class Program {
static void Main(string[] args) {
Console.WriteLine("Please enter your name:");
string name1 = Console.ReadLine();
string name2 = Console.ReadLine();
Console.Write("Welcome to you ,{0} and {1}!", name1, name2);
//加一行读取...
Console.ReadLine();
}
}
}
2010-11-23
展开全部
代码最后加一句
Consol.read();
Consol.read();
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
using System;
class Welcome
{
static void Main()
{
Console.WriteLine("Please enter your name:");
string name1 = Console.ReadLine();
string name2 = Console.ReadLine();
Console.Write("Welcome to you ,{0} and {1}!",name1,name2);
/***************************************/
Console.ReadKey();//表示等待按下一个键
/*****************************************/
}
}
class Welcome
{
static void Main()
{
Console.WriteLine("Please enter your name:");
string name1 = Console.ReadLine();
string name2 = Console.ReadLine();
Console.Write("Welcome to you ,{0} and {1}!",name1,name2);
/***************************************/
Console.ReadKey();//表示等待按下一个键
/*****************************************/
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询