请问tstring对象的用法是怎样的(0分)

  • 主题发起人 主题发起人 maxwel
  • 开始时间 开始时间
M

maxwel

Unregistered / Unconfirmed
GUEST, unregistred user!
请问tstring对象的用法是怎样的
 
是tstring还是tstringlist?查查帮助吧
 
TStrings是一个虚类;
var Ts:TStrings;
begin
Ts:=Tstringlsit.create;
...
Ts.free;
end;
 
TStrings is the base class for objects that represent a list of strings.

Unit

Classes

Description

Derive a class from TStrings to store and manipulate a list of strings. TStrings contains abstract methods and should not be directly instantiated.

Descendants of TStrings can represent several individual strings, such as the individual lines that appear in a list box. Some objects use descendants of TStrings to represent one long body of text so that it can be manipulated in smaller chunks.

TStrings introduces many properties and methods to

Add or delete strings at specified positions in the list.
Rearrange the strings in the list.
Access the string at a particular location.
Read the strings from or write the strings to a file or stream.
Associate an object with each string in the list.
 
procedure TForm1.Button1Click(Sender: TObject);
var
ss : TStrings;//定义字符串
ii : integer;
begin
ss := TStrings.Create;//实例化创建
ss.Add('the first line');//字符串操作
ss.Add('the second line');
showmessage(ss.Strings[0]);
showmesssage('一共有记录为'+inttostr(ss.Count)+'条');
for ii := 0 to ss.Count - 1 do
begin
ss.Strings[ii] := '';//用count属性清空
end;
end;

这个是一个简单的例子,呵呵,类,实例,然后使用里面的方法和属性就可以了。
 
后退
顶部