A simple extension method to safely truncate any string to a predetermined length:
public static string Truncate(this string str, int maxLength) {
if (str == null) return null;
return str.Substring(0, Math.Min(maxLength, str.Length));
}
Just call string.Truncate(int) and the returned string will be trimmed accordingly.