How can I split a string by lines... For example
Line1
Line2
Line3
I want to split it into a list
so lines[1] = "line1"
see? So how could I do this?
Printable View
How can I split a string by lines... For example
Line1
Line2
Line3
I want to split it into a list
so lines[1] = "line1"
see? So how could I do this?
Or for maximum portabilityCode:string longString = //Whatever;
string[] lines = allStringsTogether.Split("\r\n", StringSplitOptions.None);
N.B. that this scheme will give you a zero-indexed array:Code:string longString = //Whatever;
string[] lines = allStringsTogether.Replace("\r\n","\n").Split('\n');
lines[0] = "line1"