jjzjj

charToResolve

全部标签

c# - 如何将字符转换为等效的 System.Windows.Input.Key 枚举值?

我想写一个这样的函数,publicSystem.Windows.Input.KeyResolveKey(charcharToResolve){//Codegoeshere,thatresolvesthecharToResolve//intotheKeyenumeratedvalue//(Forexamplewith'.'asthecharacterforKey.OemPeriod)}我知道我可以写一个巨大的Switch-case来匹配角色,但还有其他方法吗?问题是Key枚举的字符串可能与字符不匹配,因此Enum.IsDefined将不起作用有什么想法吗?更新:这是在Windows环境下