CSharp examples for System:String Split
Splits the text into lines.
using System.Text.RegularExpressions; using System.Collections.Generic; using System.Text; using System;/*from ww w . ja v a2s .c o m*/ public class Main{ /// <summary> /// Splits the text into lines. /// </summary> /// <param name="text">The text.</param> /// <returns></returns> public static string[] SplitIntoLines(string text) { List<string> lines = new List<string>(); StringBuilder line = new StringBuilder(); foreach (char ch in text) { switch (ch) { case '\r': break; case '\n': lines.Add(line.ToString()); line.Length = 0; break; default: line.Append(ch); break; } } if (line.Length > 0) { lines.Add(line.ToString()); } return lines.ToArray(); } }