/ Published in: C#
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
namespace System { public static class StringTruncator { /// <summary> /// Trims and truncates to specified length if required. /// </summary> public static string Truncate(this string item, int length) { return item.Trim().Substring(0, Math.Min(item.Trim().Length, length)); } } }