title: Delphi: how to use TObjectList<T>?
body: <p>I need to understand how to use the generic Delphi 2009 <code>TObjectList</code>. My non-<code>TObjectList</code> attempt looked like</p>
  
  <pre><code>TSomeClass = class(TObject)
  private
    FList1: Array of TList1;
    FList2: Array of TList2;
  public
    procedure FillArray(var List: Array of TList1; Source: TSource); Overload;
    procedure FillArray(var List: Array of TList2; Source: TSource); Overload;
  end;
  </code></pre>
  
  <p>Here, <code>TList1</code> and <code>TList2</code> inherits the same constructor <code>constructor TParent.Create(Key: string; Value: string);</code>. However, due to different specialization (e.g. different private fields), they will not be of the same type. So I have to write two nearly identical fill methods:</p>
  
  <pre><code>procedure TSomeClass.FillArray(var List: Array of TList1; Source: TSource);
  begin
    for i := 0 to Source.List1.Count - 1 do begin
      SetLength(List, Length(List) + 1);
      List[i] := TList1.Create(Source.List1[i].Key, Source.List1[i].Value);
    end;
  end;
  </code></pre>
  
  <p>with <code>FillArray(List: Array of TList2; Source: TSource);</code> being identical, except for the replacement of <code>TList1</code> with <code>TList2</code> throughout. As far as I understand, this could be neatly circumvented by using <code>TObjectList</code> and a single fill method; yet, I don't have a clue how to go about this. Do anyone have some good pointers on this? Thanks!</p>