Class StringHelper
- Namespace
- SharpConsoleUI.Helpers
- Assembly
- SharpConsoleUI.dll
Provides helper methods for string manipulation operations.
public static class StringHelper
- Inheritance
-
StringHelper
- Inherited Members
Methods
TrimWithEllipsis(string, int, int)
Trims a string to a maximum length with an ellipsis (...) inserted at a specified position.
public static string TrimWithEllipsis(string input, int maxLength, int ellipsisPosition)
Parameters
inputstringThe input string to trim.
maxLengthintThe maximum length of the resulting string including the ellipsis.
ellipsisPositionintThe position where the ellipsis should be inserted.
Returns
- string
The original string if it is shorter than or equal to
maxLength; otherwise, a trimmed string with ellipsis showing the beginning and end portions.
Examples
// Returns "Hello...World"
StringHelper.TrimWithEllipsis("Hello Beautiful World", 14, 5);
Exceptions
- ArgumentException
Thrown when arguments are invalid (null/empty input, non-positive maxLength, negative ellipsisPosition, or ellipsisPosition >= maxLength).