System.String stopped working

  • Thread starter Thread starter letter4yuting
  • Start date Start date
L

letter4yuting

In my method I tried to manipulate a string parameter using IndexOf()
method -- even though it compiles all the string methods (IndexOf,
Trim, UpperCase....) fail -- except the property Length. The strange
thing is neither compiler or run-time system generates any error:


static string ServerUrl(string server, string port, string resource)
{
// server.Length would return the correct length of string... but...

int x = server.IndexOf("/");
// x is "out of scope" when putting breakpoint here...

if(x == -1)
{
return string.Format("http://{0}:{1}/{2}", server, port, resource);
}

// execution continues without any error...

string[] parts = server.Split('/');

return string.Format("http://{0}:{1}/{2}/{3}", parts[0], port,
parts[1], resource);
}

Any ideas?
 
In my method I tried to manipulate a string parameter using IndexOf()
method -- even though it compiles all the string methods (IndexOf,
Trim, UpperCase....) fail -- except the property Length. The strange
thing is neither compiler or run-time system generates any error:

So in what way do they "fail"?

Leaving the debugger aside, can you post a short but complete program
that demonstrates the problem? See
http://www.pobox.com/~skeet/csharp/complete.html for what I mean by
that.

Jon
 
Found the reason they 'fail' -- i.e. variable doesn't contain the
desired data.

The reason it was "out of scope" was because the debugger was actually
debugging another version of executable. For some reason the modified
source code didn't get compiled but the code is pretty close to the
original VS still allows setting breakpoints etc. on the modified code.
That's why new variables don't display in the debugger...

Thanks for the info though... the problem solved itself :)
 
Back
Top