RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
AnsiString::SetLength Method

Changes the length of the System::AnsiString::AnsiString.

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

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

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

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

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!