TStringList.Names

From Soldat Community Wiki
Revision as of 19:26, 24 August 2013 by Mighty (talk | contribs) (new page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
property Names[i: Integer]: String
 Access mode: R

Description

Names provides indexed access to the names of the name-value pairs in the list. It returns the name part of the i-th string in the list.

The i is not an index based on the number of name-value pairs in the list. It is the name part of the name-value pair a string i in the list. If the string at position i is not a name-value pair (i.e. does not contain the equal sign (=)), then an empty name is returned.

Example

var
  s: TStringList;

begin
  s := File.CreateStringList();
  s.Append('a=1');
  s.Append('b=2');
  s.Append('c=3');
  s.Append('d=4');
  s.Append('e=5');

  WriteLn(s.Strings[2]);         // c=3
  WriteLn(s.Names[2]);           // c
  WriteLn(s.Values[s.Names[2]]); // 3
  
  s.Free;
end.