Generics and Classtype

Giganews Newsgroups
Subject:Generics and Classtype
Posted by: Soeren Muehlbauer (soeren.…@gmx.de)
Date:Mon, 31 May 2010

Hi,

i have the following class.

type
  TFoo = class
  end;

  TContainer = class
  private
    FList: TList<TFoo>;
  public
    function Supports<T: TFoo>(Index: Integer; out Obj: T): Boolean;
  end;

How can the function Supports can be implemented. I have tried various
ways. Some looks good but do not compile. The ones that compile consists
of hard casts which doesnt look right.

TIA, Soeren

Replies