Splits the string into lines.

   
 

//Microsoft Public License (Ms-PL)
//http://visualizer.codeplex.com/license

using System;
using System.Collections.Generic;

namespace Redwerb.BizArk.Core.StringExt
{
    /// <summary>
    /// Provides extension methods for strings.
    /// </summary>
    public static class StringExt
    {
        /// <summary>
        /// Splits the string into lines.
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static string[] Lines(this string str)
        {
            var lines = new List<string>();
            using (var sr = new System.IO.StringReader(str))
            {
                string line = sr.ReadLine();
                while (line != null)
                {
                    lines.Add(line);
                    line = sr.ReadLine();
                }
            }

            return lines.ToArray();
        }
   }
}        

   
     


This entry was posted in Data Types. Bookmark the permalink.