/ Published in: C#
Truncate("This is way too long", 11, "...") returns "This is way..."
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
public static string Truncate(this string myString, int limit, string symbol) { if (myString == null)     return null;     if (limit < 0)     if (symbol == null)     if (myString.Length < limit)         return myString;     return myString.Substring(0, limit) + symbol; }