On entering negative values to a textbox I get an error saying Unhandled Exception: System.OverflowException: Value was either too large or too small for a UInt32.
Here is my code :
UInt32 n = Convert.ToUInt32(textBox2.Text);
if (n > 0)
//code
else
//code
That happens because
UInt32is unsigned. You should useInt32(which is unsigned) instead.So your code should look like:
However, I would rather put it like that: