HUH??! Help badly needed.

  • Thread starter Thread starter Chris Mayers
  • Start date Start date
C

Chris Mayers

Can someone please try this, and tell me what happens, cause either I've got
a weird bug in my VS2003, or I'm going mad...

C#
public void UpdateComments(string customerId, string comment)
{
string firstPart;
string secondPart;
int lengthOfString = comment.Length;
if (lengthOfString >= 200)
{
firstPart = comment.Substring(0,200);
secondPart = comment.Substring(200);
}
else
{
firstPart = comment;
secondPart = "";
}
<... Rest of Method...>
}

Couldn't be much simpler eh?
However if I run this in debug mode, and step through the code, then if my
string is longer or equal to 200 then all is well. IF however the string is
less than 200, the code jumps right over the else part of the method and
carries on with the 'Rest Of Method' code.

Anybody tell me what the **** is going on...?

TIA,
Chris
 
Chris Mayers said:
Can someone please try this, and tell me what happens, cause either I've
got
a weird bug in my VS2003, or I'm going mad...

C#
public void UpdateComments(string customerId, string comment)
{
string firstPart;
string secondPart;
int lengthOfString = comment.Length;
if (lengthOfString >= 200)
{
firstPart = comment.Substring(0,200);
secondPart = comment.Substring(200);
}
else
{
firstPart = comment;
secondPart = "";
}
<... Rest of Method...>
}

Couldn't be much simpler eh?
However if I run this in debug mode, and step through the code, then if my
string is longer or equal to 200 then all is well. IF however the string
is
less than 200, the code jumps right over the else part of the method and
carries on with the 'Rest Of Method' code.

Anybody tell me what the **** is going on...?

TIA,
Chris
When I call your method using a short string as the second argument, the
code follows the expected path, into the else. So, you're not going mad,
IMHO. Any other indications that your VS2003 or .NET Framework 1.1 is having
problems? Can we assume the described behavior occurs with any short string
you pass?
A guess at a shotgun solution would be to uninstall, then reinstall the .NET
Framework, as I had to do that recently on a PC that suddenly lost the
ability to find the VB compiler (C++ and C# remained fully functional).
 
It may just be a debugger problem. Try deleting the binaries (.exe,
..dll, and .pdb) and recompile.

I had a problem where the debugger was seemingly jumping to the wrong
lines or to blank lines and it was because the .pdb file was out of
synch with the exe.

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top