Wrox Programmer Forums
|
BOOK: Beginning Visual C# 2010
This is the forum to discuss the Wrox book Beginning Visual C# 2010 by Karli Watson, Christian Nagel, Jacob Hammer Pedersen, Jon D. Reid, Morgan Skinner, ; ISBN: 9780470502266
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Visual C# 2010 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 8th, 2012, 08:04 AM
Authorized User
 
Join Date: Nov 2011
Posts: 34
Thanks: 14
Thanked 0 Times in 0 Posts
Default Chapter 12 Generics

Code:
 IEnumerator IEnumerable.GetEnumerator()
         {
             return animals.GetEnumerator();
         }


Page 358.
Can anyone explain this line of code.Thanks in advance.
 
Old January 8th, 2012, 11:05 AM
Wrox Author
 
Join Date: Sep 2010
Posts: 175
Thanks: 3
Thanked 53 Times in 53 Posts
Default

it's the example from page 258, the class Farm<T> implements the interface IEnumerable<T>. This interface defines the methods GetEnumerator() that returns IEnumerator<T>, and (derived from the interface IEnumerable) the method GetEnumerator() that returns IEnumerator.
Code:
IEnumerator IEnumerable.GetEnumerator()
{
   return animals.GetEnumerator();
}
With this code you have an explicit implementation of the GetEnumerator method of the IEnumerable interface.
The implementation just invokes the GetEnumerator method of the animals variable that is of type List<T>.
__________________
Christian
CN innovation
Visit my blog at: csharp.christiannagel.com
Follow me on twitter: @christiannagel
The Following User Says Thank You to ChristianNagel For This Useful Post:
dampyr (January 9th, 2012)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 12 thepianoguy BOOK: Professional iPhone and iPad Application Development 7 May 30th, 2011 11:13 AM
Generics chapter 12 difficult chapter i found ...? Larryz C# 2005 1 July 4th, 2007 09:40 PM
Chapter 12 stingo BOOK: Beginning Access 2003 VBA 0 March 1st, 2007 05:15 PM
Errors on Chapter 12 example(12.8) sonnie ASP.NET 2.0 Professional 2 June 7th, 2006 10:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.