tags:

views:

23

answers:

2

The PageContent element implements IAddChild but doesn't implements IAddChild methods so I can't call AddChild method on PageContent.. How can it be?
And if i cast PageContent to IAddChild i can call AddChild method on it - So it does implement it somewhere...

I am confused with this behavior. Can someone shed some light on this?

A: 

Explicit interface implementation :

Guillaume
So i can't see this in the sources of PageContent or in the IntelliSense? It should at least appear as "IAddChild.AddChild" and "OtherInterface.AddChild" ...
Nimrod Shory
You have to cast to (or assign a variable of) the interface type in order to see the members of the interface.You should see the Implementation within PageContent (or a base type) under IAddChild.AddChild. It might be hidden in a region.
Guillaume
@Nimrod: The intellisense only shows the members that are directly available. It could get rather complicated otherwise.
Guffa
Thanks. It must be related somehow to the IAddChildInternal interface which i cant find any documentation about and VS doesn't recognize.
Nimrod Shory
+2  A: 

The methods are implemented explicitly for the interface. That means that you can only reach them using a reference of the interface type, not using a reference of the class type.

This is usually done when the methods make sense when you use the object through the interface, but not as much for the object itself.

Guffa