CSharp examples for System:String Format
Gets the line break total in String.
using System.Globalization; public class Main{ /// <summary> /// Gets the line break total. /// </summary> /// <param name="value">The string to count line-breaks.</param> /// <returns>Total line-breaks.</returns> public static int GetLineBreakTotal(this string value) {// w w w . j a va2 s .co m return value.Count("\n") + 1; } /// <summary> /// Counts the specified text. /// </summary> /// <param name="value">The string contains text to count.</param> /// <param name="countText">The text to count.</param> /// <returns>The number of text to count occurring in string.</returns> public static int Count(this string value, string countText) { return (value.Length - value.Replace(countText, string.Empty).Length) / countText.Length; } }