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

Hard vs. Soft Water: What's The Difference?

Weed, Guns & Minimum Wage: What Else Is The U.S. Voting On?

The Ten Most Livable Cities In The World