#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2005
    Posts
    227
    Rep Power
    0

    Tab Split String Now Working.


    Tab Split String Now Working.

    Please Help. I wrote a C# program that reads code one line at a time. Each line has data seperated by tabs.

    Here is what my C# code is supposed to do. The line is supposed to be split into a string array by using the "Split" string methodIt is supposed to be spit read in text one line at a time and I use the "Split" method to group the line according to the tab character.

    But, as this screen shot shows, it does not work. Any idea why?

  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    14
    Rep Power
    0
    You've got a breakpoint on that line... There's nothing really wrong with your code from what code I can see where the popups don't block it, but I'm seeing a breakpoint there, so regardless of whether it's right or wrong, it's always going to break at that line while debugging at runtime...

    Instead of using Convert.ToUInt32 you could use the TryParse or Parse methods for Integer/UInteger types also... And as long as arr.Split('\t') is a length of 4 elements, index [3] should exist, therefore, you have no problem.

    ~Ace
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2011
    Posts
    140
    Rep Power
    0

    Try this for split the string


    Hi

    Please find the answer of the question
    Try this for split the string: string [] arr = line.Split(new char[]{'\t'});

    Thanks & Regards
    Diya
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    14
    Rep Power
    0
    This won't do a whole lot, the preferred version is actually what OP is doing with Split('\t'). No need to provide it with a new char[] array with '\t' as the only element. The real issue here is more likely 1 of 2 things:

    1) He/she is unaware that a breakpoint is active on that line
    2) The number of elements of that split string array, is less than a length of 4 elements.

    Cheers
    ~Ace

IMN logo majestic logo threadwatch logo seochat tools logo