If I have a variable that contains text information (for example, taken from a text field), how can I read the text content contained in a string variable by a string?
The text entered in the text area will have \ n (enter the key) to separate the line.
You can use StringReader:
StringReader
var reader = new StringReader(textbox.Text); string line; while (null != (line = reader.ReadLine())) { //... }
Try using
string[] strings = yourString.Split(new string[] {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries)
string[] splitInput = System.Text.RegularExpressions.Regex.Split( InputString, "\r\n");
, ! :
myString.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries)