我发现了问题
问题在于MonoDevelop,它在控制台中运行良好。谢谢你的帮助。
我正在使用C#控制台应用程序并且我已经构建了一个简单的菜单,当要求用户输入时它没有显示输入的第一个字符。
这是我的代码。
Console.Write("Input >");
string result = Console.ReadLine();
switch(result) {
case "1":
Console.WriteLine("1");
break;
case "2":
Console.WriteLine("2");
break;
default:
Console.WriteLine("Invalid");
break;
}
- 编辑 - 实际代码
Console.Write("\t\t\t+");
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write("-----------------------------");
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("+");
Console.Write("\t\t\t|");
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("---MENU----------------------");
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("|");
Console.Write("\t\t\t|");
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("------|1|-HELP MENU----------");
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("|");
Console.Write("\t\t\t|");
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("------|2|-INITIATE CHAT------");
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("|");
Console.Write("\t\t\t|");
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("------|3|-CONFIGURATION -----");
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("|");
Console.Write("\t\t\t+");
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write("-----------------------------");
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("+");
Console.ForegroundColor = ConsoleColor.White;
string result = Console.ReadLine();
menuInput(result);
答案 0 :(得分:2)
与我合作
Console.Write("\t\t\t+");
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write("-----------------------------");
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("+");
Console.Write("\t\t\t|");
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("---MENU----------------------");
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("|");
Console.Write("\t\t\t|");
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("------|1|-HELP MENU----------");
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("|");
Console.Write("\t\t\t|");
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("------|2|-INITIATE CHAT------");
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("|");
Console.Write("\t\t\t|");
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("------|3|-CONFIGURATION -----");
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("|");
Console.Write("\t\t\t+");
Console.ForegroundColor = ConsoleColor.Yellow;
Console.Write("-----------------------------");
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("+");
Console.ForegroundColor = ConsoleColor.White;
Console.Write("Input >");
string result = Console.ReadLine();
switch (result)
{
case "1":
Console.WriteLine("1");
break;
case "2":
Console.WriteLine("2");
break;
default:
Console.WriteLine("Invalid");
break;
}
Console.ReadLine();