डेल्फी 2010 में, मैं एक सामान्य TInterfaceList इस प्रकार परिभाषित किया है:क्या डेल्फी जेनेरिक टीइंटरफेसलिस्ट संभव है?
type
TInterfaceList<I: IInterface> = class(TInterfaceList)
function GetI(index: Integer): I;
procedure PutI(index: Integer; const Item: I);
property Items[index: Integer]: I read GetI write PutI; default;
end;
implementation
function TInterfaceList<I>.GetI(index: Integer): I;
begin
result := I(inherited Get(Index));
end;
procedure TInterfaceList<I>.PutI(index: Integer; const Item: I);
begin
inherited Add(Item);
end;
मैं किसी भी समस्याओं अभी तक नहीं किया है था, लेकिन वहाँ कुछ भी स्वाभाविक ऐसा करने के बारे में जोखिम भरा है? क्या ..in loops पर काम करने की अनुमति देने के लिए इसमें एक गणनाकर्ता जोड़ना संभव होगा? यदि इसमें कुछ भी गलत नहीं है, तो मुझे आश्चर्य है कि कुछ ऐसा क्यों आरटीएल में पहले से परिभाषित नहीं किया गया है।