all groups > dotnet clr > august 2005 >
You're in the

dotnet clr

group:

Overriding explicit implementation


Overriding explicit implementation nickdu
8/26/2005 11:40:32 AM
dotnet clr: Is there a way to override an explicit implementation, say
CollectionBase.IList.Insert(), and then in my override defer to that
implementation? I've been able to override that implementation (though I was
suprised that I needed to add IList to my class's inheritance), but I can't
see anyway to call down to CollectionBase's implementation. In reality the
OnXXX() protected virtuals that CollectionBase supports may be all I need,
but I'm not sure of that yet.

--
Thanks,
RE: Overriding explicit implementation TaylorMichaelL
9/5/2005 10:57:03 AM
You can not override an interface implementation in a base class unless the
base class makes the implementation virtual. A virtual method and an
interface implementation are independent things. Most classes that provide a
base implementation of an interface provide virtual methods to override to
change the interface behavior. In the case of CollectionBase you should
implement the OnInsert and/or OnInsertComplete methods to implement how the
insertion works. If you for some reason you need more control then you
should not use CollectionBase. Instead you should either embed an instance
of CollectionBase in your custom collection or simply handle the collection
management yourself. Either way implement the appropriate interfaces (IList,
etc.) in your custom class.

Michael Taylor - 9/5/05

[quoted text, click to view]
AddThis Social Bookmark Button