[JEDI.NET discuss] Explicit interface member implementations
Status: Pre-Alpha
Brought to you by:
jedi_mbe
|
From: Marcel B. <ma...@ze...> - 2004-06-17 14:03:01
|
Hi there .NET gurus
C# has the concept of explicit interface member implementations:
---8<--
interface ICloneable
{
object Clone();
}
interface IComparable
{
int CompareTo(object other);
}
class ListEntry: ICloneable, IComparable
{
object ICloneable.Clone() {...}
int IComparable.CompareTo(object other) {...}
}
Here, ICloneable.Clone and IComparable.CompareTo are explicit interface member implementations.
---8<--
(the above was blatantly copied from the .NET Framework documentation). Delphi doesn't seem to allow this, so either I'm
missing something or this is really not possible in Delphi (that would be a shame not a real big issue).
While on the subject of interfaces: I posted this today in QC (#8436):
---8<---
When declaring a class like below, the compiler will issue the hint 'Private symbol CompareTo declared but never used'. This is
wrong, since the method is used by the IComparable interface.
type
MyClass = class (TObject, IComparable)
strict private
function CompareTo(obj: TObject): Integer;
end;
In addition the following declaration will return a compiler error (Undeclared identifier 'MyComparer') followed by a hint
(Private symbol MyComparer declared but never used).
type
MyClass = class (TObject, IComparable)
strict private
function MyComparer(obj: TObject): Integer;
function IComparable.CompareTo = MyComparer;
end;
---8<---
--
Marcel Bestebroer (Team JEDI) http://delphi-jedi.org
Project JEDI Help coordinator
JEDI.NET team coordinator
|