Wanted: Practical Example of Multiple Interfaces in C#...

J

Jason

Hello,

I'm interested in getting some code for a practical example of
multiple inheritance with interfaces in C#. By practical I mean
something like a banking system or something. For example, perhaps
you have different types of accounts such as savings accounts and
checking accounts, etc.? Doesn't have to be a banking system, but a
real world business example rather than the ones given in tutorials
(i.e.: "car, truck, pickup" or "dog, cat, mammel", etc).

I'm interested in taking my understanding of this to the next level
and seem to only come across the tutorial examples. I'd like an
example that shows an implementation in the business world.

Thanks
Jason
 
P

Paul

Interface implementation not inheritance. Think of interfaces as
implementation of a contract rather than inheritance of functionality?
Somone one here can probably explain better than me.

Why not pull examples from the framework as I find it very unlikely someone
will just drop you their code.

System.Data.Common.DbDataReader implements these and is pretty practical,
well for all of us anyway. Not only that but its abstract so then you can go
on and checkout examples of inheritance. Good luck.

IDataReader
IDataRecord
IDisposable
IEnumerable
 
G

Gregory A. Beamer

I'm interested in getting some code for a practical example of
multiple inheritance with interfaces in C#. By practical I mean
something like a banking system or something. For example, perhaps
you have different types of accounts such as savings accounts and
checking accounts, etc.? Doesn't have to be a banking system, but a
real world business example rather than the ones given in tutorials
(i.e.: "car, truck, pickup" or "dog, cat, mammel", etc).

I agree with Paul about the Framework bits, only I think I would look at
containers, as they are easier to grasp.

Take Dictionary<TKey, TValue> for example.

You have the IDictionary<TKey, TValue> interface, which is also used on
the SortedDictionary<TKey, TValue> class. This interface allows a
programmer to set up code that can use the Dictionary specific bits
without worrying about type.

You also have the IEnumerable interface, which allows you to iterate
through the collection.

The main benefit of multiple interfaces is being able to focus on
behavior rather than specific objects. This allows you to more loosely
couple software, as you are working on interfaces, not objects.

Peace and Grace,


--
Vote for Miranda's Christmas Story
http://tinyurl.com/mirandabelieve

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 

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