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

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
 
N

Nicholas Paldino [.NET/C# MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top