Skip to main content
Version: 4.0 (next)

Humanizer.DynamicNumberOfCharactersAndPreserveWordsTruncator

DynamicNumberOfCharactersAndPreserveWordsTruncator Class

Truncate a string to a fixed number of letters or digits, preserving whole words by never cutting a word in half. If a complete word (plus the delimiter, if any) cannot fit, then only the delimiter is returned. When truncating from the left, the delimiter is prepended if a complete word can be preserved; otherwise, only the delimiter is returned. The allowed count is computed by counting only letters/digits.

public class DynamicNumberOfCharactersAndPreserveWordsTruncator : Humanizer.ITruncator

Inheritance System.Object → DynamicNumberOfCharactersAndPreserveWordsTruncator

Implements ITruncator

Methods

DynamicNumberOfCharactersAndPreserveWordsTruncator.Truncate(string, int, string, TruncateFrom) Method

public string? Truncate(string? value, int totalLength, string? delimiter, Humanizer.TruncateFrom truncateFrom=Humanizer.TruncateFrom.Right);

Parameters

value System.String

totalLength System.Int32

delimiter System.String

truncateFrom TruncateFrom

Implements Truncate(string, int, string, TruncateFrom)

Returns

System.String