How do I split a string into a multidimensional array or a jagged array without looping?
I saw a code snippet where someone was doing so with a file stream and I can't figure out how to make it work for my string.
My string is similar to 1:2;3:1;4:1
and can be split into ID:Qty
.
Here is the code I saw:
string[][] lines = File.ReadAllLines(path)
.Select(line => line.Split(',').ToArray()).ToArray();
Thanks in advance.
String s = "1:2;1:3;1:4";
String[][] f = s.Split( ';' ).Select( t => t.Split( ':' ) ).ToArray();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With