C#: How would you make it so D0 to D9 are converted in numeric form without the D

c

example: (e.KeyCode >= Keys.D0) && (e.KeyCode <= Keys.D9)

I'm trying to detect on a keydown event in a textbox that if a numeric key is pressed

(e.KeyCode >= Keys.D0) && (e.KeyCode <= Keys.D9), to display the e.KeyCode as a string into a listbox.

Best Answer

Assuming they are defined sequentially in the enum:

(int)key - (int)Keys.D0;