Accessing the implementing class when only an Interface reference is available - relatively new to C

  • Thread starter Thread starter Devon
  • Start date Start date
D

Devon

Hi, I'm just getting my feet wet with C# and need some help with interface
implementation.
I want to create a collection of various objects that implement a certain
interface (i.e. IMyInterface). Each object will have additional methods
which are unique to their class. The collection will only accept types
IMyInterface but I want to be able to access any object in the collection
via the interface or the implementing class. Is this possible when the
collection only holds objects of type IMyInterface? Thanks for the help.

Devon
 
Jeff and Devon,

It should also be noted that this generally is a bad idea, because you
are circumventing the whole idea of having interfaces.
 
Back
Top