TStringList.Equals

From Soldat Community Wiki
Jump to: navigation, search
function Equals(Strings: TStrings): Boolean
 Strings: strings that are compared with the list

Description

Equals compares the contents of the stringlist with the contents of Strings. If the contents match, i.e. the stringlist contain an equal amount of strings, and all strings match, then True is returned. If the number of strings in the lists is unequal, or they contain one or more different strings, False is returned.

  • The strings are compared case-insensitively.
  • The associated objects are not compared

Example

var
  s1,s2: TStringList;
  res: Boolean;

begin
  s1 := File.CreateStringList();
  s1.Append('a');
  s1.Append('b');
  s1.Append('c');

  s2 := File.CreateStringList();
  s2.Append('a');
  s2.Append('b');
  s2.Append('c');

  res := s1.Equals(s2);
  // res = TRUE
  
  s1.Append('d');
  
  res := s1.Equals(s2);
  // res = FALSE
  
  s1.Free;
  s2.Free;
end.