Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
public static string CharacterLimit(this string text, int length)
if (text.Length <= length) return text;
int pos = text.IndexOf(" ", length);
if (pos >= 0) return text.Substring(0, pos) + "...";
return text;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment