System.AnsiStringT.SetLength

From RAD Studio API Documentation
Jump to: navigation, search

C++

AnsiStringT&  SetLength(int newLength) {

Properties

Type Visibility Source Unit Parent
function public dstring.h System AnsiStringT

Description

Changes the length of the AnsiStringT.

SetLength changes the string's length to newLength, truncating if necessary.

SetLength reallocates the underlying array of characters that stores the value of the AnsiStringT. Existing characters in the string are preserved, but the content of newly allocated space is undefined. If there is not enough memory available to reallocate the AnsiStringT, an EOutOfMemory exception is thrown. Following a call to SetLength, the AnsiStringT is guaranteed not to be a shared reference.

SetLength returns the modified AnsiStringT object.