c# - Why is the else not a valid expression -
the error i'm getting code else invalid expression term. why this?
private void button2_click(object sender, eventargs e) { int magicnumber; if(int.tryparse(textbox2.text,out magicnumber)); { messagebox.show ("your number " + magicnumber); } else { messagebox.show("failure"); } }
you closed if
statement semicolon:
if(int.tryparse(textbox2.text,out magicnumber));
the block below declares new scope, , execute. else
block below that has no matching if
, error.
Comments
Post a Comment