我正在编写基于文本的冒险,并且遇到了问题.我正在尝试创建一个switch语句案例来处理您想要的每个考试操作,并且到目前为止我的代码正在获取此代码:
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;
Run Code Online (Sandbox Code Playgroud)
如何在case语句中使用变量?我想要任何以"examine"+(x)开头的字符串来触发这个案例.