CSharp examples for System:String Shorten
Shrink string with ...
using System.Text.RegularExpressions; using System.Linq; using System.Collections.Generic; using System;/*w w w.j a va 2s . c om*/ public class Main{ public static string Take(this string str, int count, bool ellipsis = false) { var lengthToTake = Math.Min(count, str.Length); var cutDownString = str.Substring(0, lengthToTake); if (ellipsis && lengthToTake < str.Length) cutDownString += "..."; return cutDownString; } }