p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning Visual C# 2005 (http://p2p.wrox.com/forumdisplay.php?f=222)
-   -   About Chapter 11 Exercise 2 (http://p2p.wrox.com/showthread.php?t=46444)

rrodrigo August 11th, 2006 08:32 PM

About Chapter 11 Exercise 2
 
Ch11Ex02 Implementing an Animal Collection example works the same when I comment out the indexer code. So, what’s the use of the indexer. I don't get the point. Is this a bad example? Or am I not understanding something? I need an example where the indexer code gets hit when I step through the code...


Karli October 30th, 2006 03:20 PM

Hi there,

Example Ch11Ex02 is a general example for defining a collection, and not just of implementing an indexed. However, the code for an indexer is included to illustrate how to add one. The code in the example does not make use of this indexer, but you can check that it's working in your code by adding the following line:

animalCollection[0].Feed();

Without the indexer this code will not compile.

I hope that helps, and perhaps you are right that the example should include code that uses the indexer.

Cheers,

Karli

----------
www.karliwatson.com
IT Specialist & Author
Technical Director, www.3form.net


All times are GMT -4. The time now is 04:49 PM.

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