HUH??! Help badly needed.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chris Mayers

    #1

    HUH??! Help badly needed.

    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.Substri ng(0,200);
    secondPart = comment.Substri ng(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


  • Peter van der Goes

    #2
    Re: HUH??! Help badly needed.


    "Chris Mayers" <chris_mayersBL UE@SUEDEYahoo.C om> wrote in message
    news:%23q%23vCn XUFHA.3716@TK2M SFTNGP12.phx.gb l...[color=blue]
    > 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.Substri ng(0,200);
    > secondPart = comment.Substri ng(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
    >[/color]
    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).

    --
    Peter [MVP Visual Developer]
    Jack of all trades, master of none.


    Comment

    • Chris Dunaway

      #3
      Re: HUH??! Help badly needed.

      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

      Comment

      Working...