我如何...程序'[12264] consoleapp1.exe'已退出代码0(0x0)。 [英] How do i...the program '[12264] consoleapp1.exe' has exited with code 0 (0x0).
问题描述
使用System;
使用System.Collections.Generic;
使用System.Linq;
使用System.Text;
使用System.Threading.Tasks;
命名空间ConsoleApp1
{
class Program
{
static void Main(string [] args)
{
int userAge;
Console.Write(请输入你的年龄:);
userAge = Convert.ToInt32(Console.ReadLine());
if(userAge< 0 || userAge> 100)
{
Console.WriteLine(无效年龄);
Console.WriteLine(年龄必须在0到100之间);
}
else if(userAge< 18)
Console.WriteLine(抱歉你未成年);
else if(userAge< 21)
Console.WriteLin e(你需要父母的同意);
else
{
Console.WriteLine(恭喜!);
Console.WriteLine(你可以报名参加活动);
}
}
}
}
它运行fune,但是一旦我按下enter键,应用程序就会自动消失....我该如何解决?
我尝试过:
debug s'ConsoleApp1.exe'(CLR v4.0.30319 :DefaultDomain):已加载'C:\ WINDOWS \Microsoft.Net \assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'。跳过加载符号。模块已经过优化,调试器选项Just My Code已启用。
'ConsoleApp1.exe'(CLR v4.0.30319:DefaultDomain):已加载'c:\ usersrs \ fe fei \ documents \ visual studio 2017 \Projects\ConsoleApp1 \ConsoleApp1 \ bin \Debug \ConsoleApp1.exe'。已加载符号。
程序'[12264] ConsoleApp1.exe'已退出,代码为0(0x0)。
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 userAge;
Console.Write("Please enter your age: ");
userAge = Convert.ToInt32(Console.ReadLine());
if (userAge < 0 || userAge > 100)
{
Console.WriteLine("Invalid Age");
Console.WriteLine("Age must be between 0 and 100");
}
else if (userAge < 18)
Console.WriteLine("Sorry you are underage");
else if (userAge < 21)
Console.WriteLine("You need parental consent");
else
{
Console.WriteLine("Congratulations!");
Console.WriteLine("You may sign up for the event");
}
}
}
}
it runs fune, but the application disappeared automatically once I hit enter.... how can I solve it?
What I have tried:
debug s'ConsoleApp1.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ConsoleApp1.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'c:\users\li fei\documents\visual studio 2017\Projects\ConsoleApp1\ConsoleApp1\bin\Debug\ConsoleApp1.exe'. Symbols loaded.
The program '[12264] ConsoleApp1.exe' has exited with code 0 (0x0).
推荐答案
使用Console.ReadKey()
或在Main()结束时的Console.ReadLine()
。
这篇关于我如何...程序'[12264] consoleapp1.exe'已退出代码0(0x0)。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!