一个数组 setlength 为10 ,后来想长度增加1 ,原先的数据不变,请问怎么操作?
解决方案 »
- 新手上路,关于csv(excel文件)类型的读数据问题,能否使用F1BOOK控件,请高手指教,谢谢!
- Socket客户端如何实现多个连接以提高通讯速度?(急)
- 怎样取XML文件中的值?
- 关于messagebox的问题?
- 能和我说说delphi中的pchar吗?最好具体说说其用法,应该注意的地方?谢谢
- 求TurboPascal7.0 的函数表
- 关于专升本的问题!
- 今天写程序遇到一些问题,多线程的程序怎样做
- 请教如何获得文件的路径?
- 请问怎样使form中的component响应windows消息﹐For example:不用delphi自带的事件处理器﹐点击form上的一个button﹐出现提示框!
- 关于ADOQUERY的列名问题。
- 在Delphi中如何在数据库中保存和读取照片
原有数据会保留的
procedure SetLength(var S; NewLength: Integer);DescriptionS is a Delphi string or dynamic-array variable.NewLength is the new number of characters or elements in S.For a short-string variable, SetLength simply sets the length-indicator character (the character at S[0]) to the given value. In this case, NewLength must be a value between 0 and 255.For a long-string or dynamic-array variable, SetLength reallocates the string or array referenced by S to the given length. Existing characters in the string or elements in the array are preserved, but the content of newly allocated space is undefined. The one exception is when increasing the length of a dynamic array in which the elements are types that must be initialized (strings, Variants, Variant arrays, or records that contain such types). When S is a dynamic array of types that must be initialized, newly allocated space is set to 0 or nil.
MyArray:Array of Byte;SetLength(MyArray, High(MyArray)+2); MyArray[High(MyArray)]:=100;
原有数据会保留的