Hello All.
Redlightpacket:
You have to remember, .NET is all about strong types. e.KeyChar returns type "char", and Keys returns "System.Windows.Forms.Keys", which is an enumeration.
If you recall from the docs, there are no implicit type casts applied to enumerations. You have to use an explicit type cast, like this:
if (e.KeyChar < (char)Keys.D0 || e.KeyChar > (char)Keys.D9)
This way, you are comparing items of the same type.
HTH.
|