473,394 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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

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
Nov 15 '05 #1
1 1329
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.
--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com

"Jeff Louie" <je********@yahoo.com> wrote in message
news:eK**************@tk2msftngp13.phx.gbl...
Devon... For a given object in the collection, you should be able to
cast
the returned reference to a valid type supported by the given object.

http://www.geocities.com/jeff_louie/OOP/oop6.htm.

Regards,
Jeff
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.<

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Paul | last post by:
Have a problem/Question - I have created a C# class that inherits from MarshalByRefObject as well as implements a custom Interface that I have created. The thing that is not working is that when...
5
by: Paul | last post by:
OK...I must be missing something...can someone tell me what I'm not doing properly... First, create an assembly with a single interface in VB.NET as follow Public Interface IDo Function...
6
by: Martyn Lawson | last post by:
Hi, I am currently working as an Analyst on a .NET Web Project using ASP.NET and C#.NET. I have a couple of, at least what should be, quick questions: 1. My understanding of UML says that...
6
by: TB | last post by:
I understand the basics of finalization and implementing IDisposable and how one is guaranteed access to managed objects only when working through the IDisposable interface. My question is to what...
2
by: Sergey Romanov | last post by:
I have two window app. I have Tree in main window and in code of that window I have function BuildTree(); This function start with tree.Clear(); So it completely rebuild tree. When I open other...
4
by: John C | last post by:
I'm new to C#, so just point me at the correct reference material if this question has been answered before. When creating a new class which implements the IDictionary interface, two versions of...
4
by: John | last post by:
I am having a problem accessing the members in a structure via an interface and Class. ***Development Code*** Structure Person Public Name as String End Structure Interface IData Public...
6
by: Joseph Geretz | last post by:
I have the following class which I am serializing and passing back and forth between my Web Service application and the client. public class Token : SoapHeader { public string SID; public...
0
by: Roger Stoller | last post by:
Hello. I have developed a COM object using ATL. It seems to work fine when accessing it from VB.NET most of the time. However, I want to use a delegate in VB to asynchronously run a method in...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.