RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
AnsiStringBase::SetLength Method

Changes the length of the System::AnsiStringBase.

Pascal
function SetLength(newLength: Integer; codePage: Integer): AnsiStringBase&;
C++
__fastcall AnsiStringBase& SetLength(int newLength, int codePage);

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

System::AnsiStringBase::SetLength reallocates the underlying array of characters that stores the value of the System::AnsiStringBase. 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 System::AnsiStringBase, an EOutOfMemory exception is thrown. Following a call to System::AnsiStringBase::SetLength, the System::AnsiStringBase is guaranteed not to be a shared reference. 

System::AnsiStringBase::SetLength returns the modified System::AnsiStringBase object (*this) 

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!