我定义了一个字符数组 char[] str;现在我想将  Keys.    就是这个 .  后面 我如何将char[0] 的值传进来!本来是 Key.   这个点后面只能写他规定好的!

解决方案 »

  1.   

    Keys. char[0]
    Keys是个什么?
    //如果是个枚举
                Enum.GetName(typeof(Keys), 1);//根据枚举值获得枚举名称
                Enum.ToObject(typeof(Keys),1)//把一个枚举值转换为对应的枚举类型
                Enum.Parse(typeof(Keys), "第一");//把字符串转换为对应的枚举类型
    //如果只个类
                typeof(Keys).GetField("FieldName")//根据字段名字获得字段值
      

  2.   

                    KeyboardIncantationMonitor.KeysIncantation tInc = m_KeyBackDoor.NewIncantation() as KeyboardIncantationMonitor.KeysIncantation;
                    //KeyboardIncantationMonitor.KeysIncantation t = m_KeyBackDoor.NewIncantation() as KeyboardIncantationMonitor.KeysIncantation;
                    
                    //! 初始化这个暗号为:依次按下 <Esc>Bye<Enter>
                    tInc.AddKey(Keys.Escape);
                    tInc.AddKey(Keys.H);
                    tInc.AddKey(Keys.Y);
                    tInc.AddKey(Keys.E);
                    tInc.AddKey(Keys.Enter);
      

  3.   


    Keys k = (Keys)Enum.ToObject(typeof(Keys), (int)char[0]);
      

  4.   


    我这样写:
    Keys keydown1 = (Keys)Enum.Parse(typeof(Keys), anwen[0]);编译无错,运行报错:未将对象引用设置到对象的实例
      

  5.   


    我这样写:
    Keys keydown1 = (Keys)Enum.Parse(typeof(Keys), anwen[0].tostring());编译无错,运行报错:未将对象引用设置到对象的实例
      

  6.   


    我这样写:
    Keys keydown1 = (Keys)Enum.Parse(typeof(Keys), anwen[0].tostring());编译无错,运行报错:未将对象引用设置到对象的实例
      

  7.   


    Keys keydown1 = (Keys)Enum.Parse(typeof(Keys), (int)anwen[0]);
      

  8.   

    Keys keydown1 = (Keys)Enum.Parse(typeof(Keys), ((int)anwen[0]).ToString());
      

  9.   

    直接
    Keys key=(Keys)'A'
    就行