Returns the number of lines appearing in target where a line is counted as a '\n'
using System.Globalization;
using System.Linq;
using System.Text;
namespace jQueryBuddy.Utilities
{
publicstaticclass StringExtensions
{
/// <summary>
/// Returns the number of lines appearing in <paramref name="target"/>
/// where a line is counted as a '\n'
/// </summary>
/// <param name="target"></param>
/// <returns></returns>
publicstaticint CountOfLines(this string target)
{
if (string.IsNullOrEmpty(target)) return 0;
return target.Count(t => t == '\n') + 1;
}
}
}