RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
AnsiStringT::SetLength Method

Changes the length of the System::AnsiStringT.

Pascal
function SetLength(newLength: Integer): AnsiStringT&;
C++
__fastcall AnsiStringT& SetLength(int newLength);

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

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

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

 

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