Table of Contents

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

input string

The input string to trim.

maxLength int

The maximum length of the resulting string including the ellipsis.

ellipsisPosition int

The 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).