I have a string that contains a known number of double values. What's the cleanest way (via C#) to parse the string and plug the results into matching scalar variables. Basically, I want to do the equivalent of this sscanf
statement, but in C#:
sscanf( textBuff, "%lg %lg %lg %lg %lg %lg", &X, &Y, &Z, &I, &J, &K );
... assuming that "textBuff
" might contain the following:
"-1.123 4.234 34.12 126.4 99 22"
... and that the number of space characters between each value might vary.
Thanks for any pointers.
or
You can use String.Split(' ', StringSplitOptions.RemoveEmptyEntries) to split it into "single values". Then it's a straight Double.Parse (or TryParse)