我正在编写一个基于文本的冒险游戏,遇到了一个问题。我想要创建一个 switch 语句 case 来处理所有你想要进行的检查操作,目前我的代码如下:
case "examine" + string x:
//this is a method that I made that makes sure that it is an object in the area
bool iseobj = tut.Check(x);
if (iseobj)
x.examine();
else
Console.WriteLine("That isn't an object to examine");
break;
如何在 case
语句中使用变量?我想要以 "examine" + (x) 开头的任何字符串都触发 case。
Console.WriteLine("That isn't an object to examine");
吗? - julianstark999