所以我试图做一个简单的文字游戏。我想做“是/否”的对话,我试图弄清楚两个小时,但是我没有找到解决问题的办法。我是个初学者,所以我不太了解编码。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TEXTRPG
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Greetings, stranger.");
Console.ReadKey();
Console.WriteLine("I've came here to give you a quest.");
Console.ReadKey();
Console.WriteLine("Do you accept?");
//Yes/No
Console.ReadKey();
答案 0 :(得分:0)
这是我的样品
do {
Console.Write("Do you accept? [y/n] ");
response = Console.ReadKey(false).Key;
if (response != ConsoleKey.Enter)
Console.WriteLine();
} while (response != ConsoleKey.Y && response != ConsoleKey.N);