c# parsing

Discussion in 'Software' started by mastermosley, Jan 11, 2010.

  1. mastermosley

    mastermosley Sergeant

    I'm trying to parse a bunch of data. My data is stored in data which is just a bunch of numbers like: 12322, 34322, 5332 3223, 3432, 343.
    Code:
     
    Char[] sep = new char[2]
    sep[0] = ',';
    sep[1] = ' ';
    
    data.split(sep)
    
    The problem is that its not seperating the whitespaces instead of
    split[2] = 5332
    split[3] = 3223 * like I want it too

    split[2] = 53323223

    Is there a special character for whitespace?
     
  2. SWario

    SWario Sergeant

    Why are you using char arrays and not strings? Char does not have a method "split" in C#, but String does.

    See the below links for reference.
    http://msdn.microsoft.com/en-us/library/system.string.split%28VS.71%29.aspx

    http://dotnetperls.com/string-split
     
  3. Wyatt_Earp

    Wyatt_Earp MajorGeek

    If you can post the actual code, we may be able to help. From what you've described, it should work, although I think your output will be something like:

    split[0] - "12322"
    split[1] - ""
    split[2] - "34322"
    split[3] - ""
    split[4] - "5332"
    split[5] - "3223"
    split[6] - ""
    split[7] - "3432"
    split[8] - ""
    split[9] - "343"
     
  4. mastermosley

    mastermosley Sergeant

  5. SWario

    SWario Sergeant

    Ah, you are correct. Next time I post that late at night, I have to pay a bit more attention. >.<
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds