Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning Microsoft Visual C# 2008 ISBN: 978-0-470-19135-4
This is the forum to discuss the Wrox book Beginning Microsoft Visual C# 2008 by Karli Watson, Christian Nagel, Jacob Hammer Pedersen, Jon D. Reid, Morgan Skinner, Eric White; ISBN: 9780470191354
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Microsoft Visual C# 2008 ISBN: 978-0-470-19135-4 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 18th, 2009, 07:14 AM
Registered User
Join Date: Sep 2009
Location: Warsaw, Poland / DE, USA
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Lightbulb Understanding Interfaces

So I'm having a bit of a tough time understanding Interfaces. On page 199 we have an example:
Cow myCow = new Cow();
Chicken myChicken = new Chicken();
IConsume consumeInterface;
consumeInterface = myCow;
consumeInterface = myChicken;
And i wondered to myself -- why would i want to do any of this? So I asked for help from a C++ programmer.
Can someone please let me know if i understand this correctly now?
  • An interface is a contract - by implementing an interface, i agree to implement all the functions in that interface for my class.
  • Interfaces in C# are a way to do multiple inheritance that's available in C++
  • By assigning an object reference (as above) to an interface variable type, I'm basically using polymorphism like normal, but with C# i can't have multiple inheritances, so i need to do it with an interface.

And that's pretty much it, right? If anyone can shed further light on this, i'd greatly appreciate it.

As much as I enjoy Wrox books, i think the chapters devoted to OOP, polymorphism and Interfaces lack a lot as far as making the reader understand. The how is explained, but not the why...

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Two interfaces with Same function name Manoj Bisht C# 2005 5 March 25th, 2009 09:52 AM
returning interfaces mike72 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 April 17th, 2008 05:53 AM
interfaces malli_kv2 Java Basics 1 April 23rd, 2007 05:21 AM
[CH04] Interfaces Norm 2782 BOOK: Professional PHP 5 ISBN: 978-0-7645-7282-1 3 June 16th, 2005 04:56 AM
Polymorphism with Interfaces digby_dog VB.NET 2002/2003 Basics 2 May 11th, 2005 12:50 PM

All times are GMT -4. The time now is 11:43 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.