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?
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