c# - An unhandled exception occurred in mscorlib.dll -
int i=convert.toint16(textbox1.text); console.write(i);
the above lines of code showing error 'system.formatexception'
. me out.
this error means input string (textbox1.text
) in incorrect format. (ie, not number)
try using int16.tryparse
method handle errors appropriately:
short number; bool result = int16.tryparse(textbox1.text, out number); if (result) { console.writeline(number); } else { // handle error! }