There is a certain class, let's say:
TListEx<T: TBaseClass> = class ... .... procedure Sort; .... end; and there is some TNotifyEvent event where you need to call this Sort:
procedure TMyForm.ListEvent(Sender: TObject); begin .... (Sender as ??????).Sort; end; Question: what should be written instead of "?????" ? If you write TListEx<TBaseClass> , then when you call the method with Sender = TListEx<TExtClass> ( TExtClass = class(TBaseClass) ), you still get an error of the type 'invalid class typecast'.
But is the method still common? How to get around this trouble?
More precisely, at the moment I decided this as TListEx<TBaseClass>(Sender).Sort , but I would still like to do it through as for reliability.
TListEx<TBaseClass> andTListEx<TExtClass>are completely different things (they have no common ancestor). Your parameter is inherited, not the class. Therefore, it does not lead him. Now, if you had writtenTListEx<T> = class(TListEx)with thesort()method and would lead to it, then everything would be fine. - teranTListEx<T>inTListEx<T>- teran