Mega Code Archive

 
Categories / C# / Data Types
 

Count Lines In String

//The MIT License (MIT) //http://arolibraries.codeplex.com/license using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; namespace AroLibraries.ExtensionMethods.Strings {     public static class StringExt     {         public static int Ext_CountLinesInString(this string str)         {             if (str == null) throw new ArgumentNullException("String is NULL");             int counter = 1;             string[] strTemp = str.Split(new string[] { "\n" }, StringSplitOptions.None);             if (strTemp.Length > 0)             {                 counter = strTemp.Length;             }             return counter;         }     } }