truncate

Summary

Cuts off the string at the specified length (number of characters).

Signatures

Click on a signature to select it and view its documentation.

Usage

public string truncate(int length)

Returns

The string cut to the specified length with the removed text replaced with a single ... ellipsis.

Parameters

length

The number of characters to limit the string to before cutting off characters (zero-based). If this number is negative, it will be treated as zero.

Description

The truncated characters are replaced with the ... ellipsis.

Examples

Basic Usage
1
2
3
string text = "The quick brown fox jumped over the lazy dog.";
 
Console.log(text.truncate(9)); // "The quick..."

Share

HTML | BBCode | Direct Link