开发者

.Net KeyEventArgs return vs enter

Have this in a c# .net application:

string key = e.KeyCode.ToString();

in .net 1.1 key = "enter"

in .net 3.5 key = "return"

my question is why are开发者_运维问答 they different?


The Keys enum has identical values for Enter and Return (it also has a number of other duplicates). The framework chose a different value in ToString.


Here are all of the duplicate names: This was generated by the following query in LINQPad:

Enum.GetNames(typeof(Keys))
    .GroupBy(k => Enum.Parse(typeof(Keys), k))
    .Where(g => g.Count() > 1)
    .Select(g => String.Join(", ", g.Select(k => k.ToString()).ToArray()))

Enter, Return
CapsLock, Capital
HangulMode, HanguelMode, KanaMode
KanjiMode, HanjaMode
IMEAccept, IMEAceept
Prior, PageUp
PageDown, Next
Snapshot, PrintScreen
OemSemicolon, Oem1
Oem2, OemQuestion
Oem3, Oemtilde
Oem4, OemOpenBrackets
OemPipe, Oem5
OemCloseBrackets, Oem6
OemQuotes, Oem7
Oem102, OemBackslash
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜