How do I convert e.KeyChar to an actual character value when handling keyboard events?

.net, c#, keyboard-events, keypress, winforms

Solution

Here is a simpler way of detecting if the key pressed is a digit or not:

if (char.IsDigit(e.KeyChar)) { // doSomething(); }

Problem

All I'm wanting to do is get the actual character that is pressed whenever they key is entered for the event. The only option I'm seeing is `e.KeyChar`which will give me the position rather than the character itself. What I'm wanting to do is limit the values of the key press to digits between 0-9. The way I'm doing it right now is just `if((e.KeyChar < 48 || (e.KeyChar > 57)))` This seems a bit cheap to just put in the values for 0 and 9, and I'd love to know how to get the character value itself rather than its key. EDIT: Thanks for the input; so in general is there no way to go from having the `e.KeyChar`value to the value of the input itself. I'd really like to take my event, e, and access the character pressed directly as opposed to using e.KeyChar to get a numeric representation of that value.

Original source