Created
January 13, 2018 18:41
-
-
Save hbulens/e07cf65160a206d883eff136cf59fbac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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