Create a string list for a given string which includes line separators - CSharp System

CSharp examples for System:String Split

Description

Create a string list for a given string which includes line separators

Demo Code


using System.Linq;
using System.Collections.Generic;

public class Main{
        /// <summary>
        ///     Create a string list for a given string which includes line separators
        /// </summary>
        /// <param name="aString">the given string which shall be split</param>
        /// <returns>the list of strings</returns>
        public static List<string> SplitByLineSeparator(this string aString)
        {/*from   w  w w . j  ava 2s.  com*/
            return aString.Replace("\r", "").Split('\n').ToList();
        }
}

Related Tutorials