C#: Is there a easy way to extract string that is seperated by one or more whitespaces?

Hi, everyone, I have a row of  data , they are seperated by one or more whitespace,

Is there a easy way to extract string that is seperated by one or more whitespaces

4.67600                  5.26870    5.85750      999.0     70.90    0.60300       66.50000

thank you.




Answer this question

C#: Is there a easy way to extract string that is seperated by one or more whitespaces?

  • diablo_xix

    MR. David, Thank you very much.

  • cschaeff

    Jack,

    Have a look at the String.Split method:



    string input = "4.67600 5.26870 5.85750 999.0 70.90 0.60300 66.50000"
    string values = input.Split(' ', StringSplitOptions.RemoveEmptyEntries);

    However, if you are worried about perfomance (remember to measure), you may want to manually do a for loop on each char of the string and break it up yourself.



  • C#: Is there a easy way to extract string that is seperated by one or more whitespaces?