我如何在Keys中使用变量值

时间:2014-04-04 17:48:49

标签: c# variables key

如何在Keys中使用变量的值。功能? 像这样:

string Key = "A";
if (Keys.M == e.Key)
{
    StreamReader read = new StreamReader(File.OpenRead(path));
    Key = read.ReadToEnd();
    Game.DisplayText(Key);
}

if (Keys.Key == e.Key)
{
    Game.DisplayText("It is working perfectly");
}

1 个答案:

答案 0 :(得分:0)

我认为您正在尝试parse a value枚举Keys

Keys key = (Keys)Enum.Parse(typeof(Keys), "A");