As you might know, you can give us feedback anytime about our books via https://aka.ms/tellpress. (We know you’re busy, so we’ve kept it short with just a few questions.) But because we don’t ask for personal information, we can’t respond personally to comments and questions that you leave us. So, in case the person who left us the following follows our blog, we want you to know that we sent your comment to the book’s author. First, your comment:
9780735681835 Microsoft Visual C# 2013 Step by Step
Very satisfied–Definitely would recommend
I can't get the EnumeratorTest exercise in chapter 19 to compile.
An explicit interface IEnumerator<TItem> IEnumerable<TItem>.GetEnumerator() is generated in class Tree<TItem> which is private. It then cannot be accessed by the foreach() call in EnumeratorTest. This is the situation described earlier in chapter 13 with the 'number of legs' Horse example. You seem to contradict your own earlier lesson.
And here is author John Sharp’s response:.
I suspect that the reader has made a mistake somewhere in his/her code. The foreach statement in C# hides the complexity of using an enumerator, and as long as the collection being enumerated implements the IEnumerable interface explicity (i.e., it provides an explicit implementation of GetEnumerator), then the GetEnumerator method should not be public - indeed, it cannot be public because explicit interface implementation prohibits public methods as described in Chapter 13. The key thing is that the class being enumerated must be enumerable, and the compiler handles the rest when it generates the code for the foreach statement.
Hope that helps!