Saturday, March 31, 2012

Strange "expected ;" error

I am getting an error and I can't seem to figure out why. The error is on line 32.

Compiler Error Message: CS1002: ; expected

Line 30: strScriptName=Request.ServerVariables("SCRIPT_NAME");
Line 31: strFolder="/buildlauncher/";
Line 32: If (strScriptName.IndexOf(strFolder)=-1)
Line 33: {
Line 34: strbuildlauncher="class='selected'";

The language I am using is C# and I don't seem to understand what a ; would be doing in an if statement. What I am trying to do is determine if the folder specified in the strFolder variable is in the server variable SCRIPT_NAME.There are some syntax problems here:

If (strScriptName.IndexOf(strFolder)=-1)

should probably be

if(strScriptName.IndexOf(strFolder) == -1)

Note the case sensitivity and the equality operator.

0 comments:

Post a Comment