Created
September 15, 2016 02:42
-
-
Save ddikman/e7898138aa82995003c84852b601a7de to your computer and use it in GitHub Desktop.
Helper extension method to cut a string down to a certain length.
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 class ShortenStringExtension | |
{ | |
public static string Shorten(this string input, int maxLength) | |
{ | |
if (string.IsNullOrEmpty(input)) | |
return input; | |
return input.Length <= maxLength ? input : input.Substring(0, maxLength); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment