Thanks,  that got rid of the warning.  I also did it for my
QueryForDocument method and that worked too.  My final point is this:  I
originally posted because doing the return outside of the switch seemed to
be losing the value of the variable filePath.  I done some reading and
figured that the variable scope was at the switch level so that when it was
sent back via the return which was outside of the switch it was a blank
variable.

Tried lots of different things properties etc but it always seemed to end
up blank.  Then re-organised my class so that it had more methods that did
specific things QueryForDocument and PathToDocument and now it seems to
work.

My Question is this. The following works..but what could have happened to
make the value given to the variable within the switch disappear?:

private string methodname(string parameter1)

string testvariable

switch(parameter1)

{
case: "keyword":

testvariable= "keyword";

break;

default:

testvariable ="default";

break;
} // end of switch

return testvariable;
}

now if the parameter passed to it was keyword then it should return
testvariable = keyword. Now my original post was because this didn't seem
to be the case. If the switch was within an if else statement would it
still work? or if testvariable was also declared within another method or
also at class level would this still work?

Got everything working now, thanks for your help. Just wanted to make sure
this is how the scope of the variable works.

Thanks,

John

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to