TruncateOnWordBoundary - a useful extension method for cutting a string short, but not in the middle of a word.


/ Published in: C#
Save to your folder(s)

Ever wanted a method that can truncate a string, but only on a word boundary? This method works like Substring() but doesn't snip a string in the middle of a word, i.e. it only truncates the string on a word boundary. Useful for producing a summary from long text, or when limiting the length of an input field.

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.