-
[RESOLVED] strange error
i swear soemtimes code is right but visual studio is just being silly, i've had times where the code is perfect but theres an error which is solved if u make a new project and paste in the same code:
Code:
public partial class MainPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
string username Request.QueryStringQueryString["name"];
WelcomeLabel.Text += ", " + username;
}
}
}
This bit of code has an error saying its expecting a semi-colon, anyone see the problem?
-
Re: strange error
This line is invalid:
Code:
string username Request.QueryStringQueryString["name"];
The error message is a bit misleading because it's telling you one thing when you actually need to do something else. That's not the IDE's fault though because it can't read your mind and know what you intended. The human eye can detect things like that though. I'm guessing that you meant to do this:
Code:
string username = Request.QueryStringQueryString["name"];
so you were actually missing an assignment, but the compiler didn't know that. To it it seemed like you had two statements on one line and were missing a semicolon after this part: