c# split string by lines code example

Example 1: c# separate string by a new line

var result = mystring.Split(new string[] {"\\n"}, StringSplitOptions.None);

Example 2: how to split a string by in c#

char[] separator = new[] { ',' };
var result = aiTranslatedString.Split(separator, StringSplitOptions.RemoveEmptyEntries).ToList();

Example 3: split string into lines

Just use tr command for separating words output into separate lines:
tr -s '[[:punct:][:space:]]' '\n'
Example for
cat file.txt | tr -s '[[:punct:][:space:]]' '\n'

Tags:

Misc Example