TStrings 和TStringList到底有什么区别???? 麻烦大家解答下,这个问题困扰了很久了! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://topic.csdn.net/t/20041129/23/3600006.html多看看前人的帖子吧,都有的!呵呵 TStrings是TStringList的父类。TStrings含抽象方法,未实现。 TStrings = class(TPersistent) private FDefined: TStringsDefined; FDelimiter: Char; FQuoteChar: Char; FNameValueSeparator: Char; FUpdateCount: Integer; FAdapter: IStringsAdapter; function GetCommaText: string; function GetDelimitedText: string; function GetName(Index: Integer): string; function GetValue(const Name: string): string; procedure ReadData(Reader: TReader); procedure SetCommaText(const Value: string); procedure SetDelimitedText(const Value: string); procedure SetStringsAdapter(const Value: IStringsAdapter); procedure SetValue(const Name, Value: string); procedure WriteData(Writer: TWriter); function GetDelimiter: Char; procedure SetDelimiter(const Value: Char); function GetQuoteChar: Char; procedure SetQuoteChar(const Value: Char); function GetNameValueSeparator: Char; procedure SetNameValueSeparator(const Value: Char); function GetValueFromIndex(Index: Integer): string; procedure SetValueFromIndex(Index: Integer; const Value: string); protected procedure DefineProperties(Filer: TFiler); override; procedure Error(const Msg: string; Data: Integer); overload; procedure Error(Msg: PResStringRec; Data: Integer); overload; function ExtractName(const S: string): string; function Get(Index: Integer): string; virtual; abstract; function GetCapacity: Integer; virtual; function GetCount: Integer; virtual; abstract; function GetObject(Index: Integer): TObject; virtual; function GetTextStr: string; virtual; procedure Put(Index: Integer; const S: string); virtual; procedure PutObject(Index: Integer; AObject: TObject); virtual; procedure SetCapacity(NewCapacity: Integer); virtual; procedure SetTextStr(const Value: string); virtual; procedure SetUpdateState(Updating: Boolean); virtual; property UpdateCount: Integer read FUpdateCount; function CompareStrings(const S1, S2: string): Integer; virtual; public destructor Destroy; override; function Add(const S: string): Integer; virtual; function AddObject(const S: string; AObject: TObject): Integer; virtual; procedure Append(const S: string); procedure AddStrings(Strings: TStrings); virtual; procedure Assign(Source: TPersistent); override; procedure BeginUpdate; procedure Clear; virtual; abstract; procedure Delete(Index: Integer); virtual; abstract; procedure EndUpdate; function Equals(Strings: TStrings): Boolean; procedure Exchange(Index1, Index2: Integer); virtual; function GetText: PChar; virtual; function IndexOf(const S: string): Integer; virtual; function IndexOfName(const Name: string): Integer; virtual; function IndexOfObject(AObject: TObject): Integer; virtual; procedure Insert(Index: Integer; const S: string); virtual; abstract; procedure InsertObject(Index: Integer; const S: string; AObject: TObject); virtual; procedure LoadFromFile(const FileName: string); virtual; procedure LoadFromStream(Stream: TStream); virtual; procedure Move(CurIndex, NewIndex: Integer); virtual; procedure SaveToFile(const FileName: string); virtual; procedure SaveToStream(Stream: TStream); virtual; procedure SetText(Text: PChar); virtual; property Capacity: Integer read GetCapacity write SetCapacity; property CommaText: string read GetCommaText write SetCommaText; property Count: Integer read GetCount; property Delimiter: Char read GetDelimiter write SetDelimiter; property DelimitedText: string read GetDelimitedText write SetDelimitedText; property Names[Index: Integer]: string read GetName; property Objects[Index: Integer]: TObject read GetObject write PutObject; property QuoteChar: Char read GetQuoteChar write SetQuoteChar; property Values[const Name: string]: string read GetValue write SetValue; property ValueFromIndex[Index: Integer]: string read GetValueFromIndex write SetValueFromIndex; property NameValueSeparator: Char read GetNameValueSeparator write SetNameValueSeparator; property Strings[Index: Integer]: string read Get write Put; default; property Text: string read GetTextStr write SetTextStr; property StringsAdapter: IStringsAdapter read FAdapter write SetStringsAdapter; end; TStringList = class(TStrings) private FList: PStringItemList; FCount: Integer; FCapacity: Integer; FSorted: Boolean; FDuplicates: TDuplicates; FCaseSensitive: Boolean; FOnChange: TNotifyEvent; FOnChanging: TNotifyEvent; procedure ExchangeItems(Index1, Index2: Integer); procedure Grow; procedure QuickSort(L, R: Integer; SCompare: TStringListSortCompare); procedure SetSorted(Value: Boolean); procedure SetCaseSensitive(const Value: Boolean); protected procedure Changed; virtual; procedure Changing; virtual; function Get(Index: Integer): string; override; function GetCapacity: Integer; override; function GetCount: Integer; override; function GetObject(Index: Integer): TObject; override; procedure Put(Index: Integer; const S: string); override; procedure PutObject(Index: Integer; AObject: TObject); override; procedure SetCapacity(NewCapacity: Integer); override; procedure SetUpdateState(Updating: Boolean); override; function CompareStrings(const S1, S2: string): Integer; override; procedure InsertItem(Index: Integer; const S: string; AObject: TObject); virtual; public destructor Destroy; override; function Add(const S: string): Integer; override; function AddObject(const S: string; AObject: TObject): Integer; override; procedure Clear; override; procedure Delete(Index: Integer); override; procedure Exchange(Index1, Index2: Integer); override; function Find(const S: string; var Index: Integer): Boolean; virtual; function IndexOf(const S: string): Integer; override; procedure Insert(Index: Integer; const S: string); override; procedure InsertObject(Index: Integer; const S: string; AObject: TObject); override; procedure Sort; virtual; procedure CustomSort(Compare: TStringListSortCompare); virtual; property Duplicates: TDuplicates read FDuplicates write FDuplicates; property Sorted: Boolean read FSorted write SetSorted; property CaseSensitive: Boolean read FCaseSensitive write SetCaseSensitive; property OnChange: TNotifyEvent read FOnChange write FOnChange; property OnChanging: TNotifyEvent read FOnChanging write FOnChanging; end; TStrings中含有抽象方法,是抽象类,不能实例化,必须用他的子类TStringList来实例对象,因为TStringList已经把抽象方法都实现了。 delphi 获取第三方dll取出得数据与真实数据字符个数不一致问题 如何创建一个新窗口? 用CANVAS画好图之后如何保存到文件? 关于ado问题 用DCOMConnection和SocketConnection哪个稳定? 请教关于TreeView显示的问题 一个关于新闻组的笨问题,希望别笑! 怎样使用命令行参数 能不能用delphi开发dhtml的?请告诉一般的方法!谢了 哪里有类似迅雷里的,树形 ListView 控件?我正在寻找中。 richtextbox的字体颜色怎么改? 计算一个记录体的2进制加法和
private
FDefined: TStringsDefined;
FDelimiter: Char;
FQuoteChar: Char;
FNameValueSeparator: Char;
FUpdateCount: Integer;
FAdapter: IStringsAdapter;
function GetCommaText: string;
function GetDelimitedText: string;
function GetName(Index: Integer): string;
function GetValue(const Name: string): string;
procedure ReadData(Reader: TReader);
procedure SetCommaText(const Value: string);
procedure SetDelimitedText(const Value: string);
procedure SetStringsAdapter(const Value: IStringsAdapter);
procedure SetValue(const Name, Value: string);
procedure WriteData(Writer: TWriter);
function GetDelimiter: Char;
procedure SetDelimiter(const Value: Char);
function GetQuoteChar: Char;
procedure SetQuoteChar(const Value: Char);
function GetNameValueSeparator: Char;
procedure SetNameValueSeparator(const Value: Char);
function GetValueFromIndex(Index: Integer): string;
procedure SetValueFromIndex(Index: Integer; const Value: string);
protected
procedure DefineProperties(Filer: TFiler); override;
procedure Error(const Msg: string; Data: Integer); overload;
procedure Error(Msg: PResStringRec; Data: Integer); overload;
function ExtractName(const S: string): string;
function Get(Index: Integer): string; virtual; abstract;
function GetCapacity: Integer; virtual;
function GetCount: Integer; virtual; abstract;
function GetObject(Index: Integer): TObject; virtual;
function GetTextStr: string; virtual;
procedure Put(Index: Integer; const S: string); virtual;
procedure PutObject(Index: Integer; AObject: TObject); virtual;
procedure SetCapacity(NewCapacity: Integer); virtual;
procedure SetTextStr(const Value: string); virtual;
procedure SetUpdateState(Updating: Boolean); virtual;
property UpdateCount: Integer read FUpdateCount;
function CompareStrings(const S1, S2: string): Integer; virtual;
public
destructor Destroy; override;
function Add(const S: string): Integer; virtual;
function AddObject(const S: string; AObject: TObject): Integer; virtual;
procedure Append(const S: string);
procedure AddStrings(Strings: TStrings); virtual;
procedure Assign(Source: TPersistent); override;
procedure BeginUpdate;
procedure Clear; virtual; abstract;
procedure Delete(Index: Integer); virtual; abstract;
procedure EndUpdate;
function Equals(Strings: TStrings): Boolean;
procedure Exchange(Index1, Index2: Integer); virtual;
function GetText: PChar; virtual;
function IndexOf(const S: string): Integer; virtual;
function IndexOfName(const Name: string): Integer; virtual;
function IndexOfObject(AObject: TObject): Integer; virtual;
procedure Insert(Index: Integer; const S: string); virtual; abstract;
procedure InsertObject(Index: Integer; const S: string;
AObject: TObject); virtual;
procedure LoadFromFile(const FileName: string); virtual;
procedure LoadFromStream(Stream: TStream); virtual;
procedure Move(CurIndex, NewIndex: Integer); virtual;
procedure SaveToFile(const FileName: string); virtual;
procedure SaveToStream(Stream: TStream); virtual;
procedure SetText(Text: PChar); virtual;
property Capacity: Integer read GetCapacity write SetCapacity;
property CommaText: string read GetCommaText write SetCommaText;
property Count: Integer read GetCount;
property Delimiter: Char read GetDelimiter write SetDelimiter;
property DelimitedText: string read GetDelimitedText write SetDelimitedText;
property Names[Index: Integer]: string read GetName;
property Objects[Index: Integer]: TObject read GetObject write PutObject;
property QuoteChar: Char read GetQuoteChar write SetQuoteChar;
property Values[const Name: string]: string read GetValue write SetValue;
property ValueFromIndex[Index: Integer]: string read GetValueFromIndex write SetValueFromIndex;
property NameValueSeparator: Char read GetNameValueSeparator write SetNameValueSeparator;
property Strings[Index: Integer]: string read Get write Put; default;
property Text: string read GetTextStr write SetTextStr;
property StringsAdapter: IStringsAdapter read FAdapter write SetStringsAdapter;
end; TStringList = class(TStrings)
private
FList: PStringItemList;
FCount: Integer;
FCapacity: Integer;
FSorted: Boolean;
FDuplicates: TDuplicates;
FCaseSensitive: Boolean;
FOnChange: TNotifyEvent;
FOnChanging: TNotifyEvent;
procedure ExchangeItems(Index1, Index2: Integer);
procedure Grow;
procedure QuickSort(L, R: Integer; SCompare: TStringListSortCompare);
procedure SetSorted(Value: Boolean);
procedure SetCaseSensitive(const Value: Boolean);
protected
procedure Changed; virtual;
procedure Changing; virtual;
function Get(Index: Integer): string; override;
function GetCapacity: Integer; override;
function GetCount: Integer; override;
function GetObject(Index: Integer): TObject; override;
procedure Put(Index: Integer; const S: string); override;
procedure PutObject(Index: Integer; AObject: TObject); override;
procedure SetCapacity(NewCapacity: Integer); override;
procedure SetUpdateState(Updating: Boolean); override;
function CompareStrings(const S1, S2: string): Integer; override;
procedure InsertItem(Index: Integer; const S: string; AObject: TObject); virtual;
public
destructor Destroy; override;
function Add(const S: string): Integer; override;
function AddObject(const S: string; AObject: TObject): Integer; override;
procedure Clear; override;
procedure Delete(Index: Integer); override;
procedure Exchange(Index1, Index2: Integer); override;
function Find(const S: string; var Index: Integer): Boolean; virtual;
function IndexOf(const S: string): Integer; override;
procedure Insert(Index: Integer; const S: string); override;
procedure InsertObject(Index: Integer; const S: string;
AObject: TObject); override;
procedure Sort; virtual;
procedure CustomSort(Compare: TStringListSortCompare); virtual;
property Duplicates: TDuplicates read FDuplicates write FDuplicates;
property Sorted: Boolean read FSorted write SetSorted;
property CaseSensitive: Boolean read FCaseSensitive write SetCaseSensitive;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
property OnChanging: TNotifyEvent read FOnChanging write FOnChanging;
end;