Lets say I have
string str = @"Line 1
Line 2
Line 3";
How can I turn this into an array where the 3 elements are "Line 1", "Line 2" and "Line 3".
Lets say I have
string str = @"Line 1
Line 2
Line 3";
How can I turn this into an array where the 3 elements are "Line 1", "Line 2" and "Line 3".
use this , The RemoveEmptyEntries option will remove empty lines from the text.
string[] splitted = str.Split(new string[] {System.Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries);
var strArray = str.Split(new [] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);