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

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -