As known TStringList.AddStrings accepts an Array of String or a TStrings and adds their contents to the TStringList instance that invokes it.
Given the above, consider the following code:
program project1;
uses
Classes;
type
MyClass=class
private
fData : string;
public
property Data : string read fData write fData;
end;
var
List : TStringList;
aClass : MyClass;
begin
List:=TStringList.Create;
aClass:=MyClass.Create;
List.Add('one');
aClass.fData:='two';
List.AddStrings(aClass.Data);
writeln(List.Text);
readln;
List.Free;
aClass.Free;
end.
In this case, using AddStrings, the content of a string property of an object is added. Nonetheless, the program works well. But is this behavior correct? I wasn't expecting that and it created a hard-to-find bug for me.