![]() |
Chapter 7: GameMoves.cs
Hello, I'm learning chapeter 7, which talks about the array, and emuerator. I can't understand how the GameMove.cs works. Could you help me?
Code:
Code:
Code:
_cross = Cross(); When the Code:
enumerator.MoveNext() Code:
enumerator.MoveNext() Thank you. |
The magic is the yield statement.
The yield statement creates an enumerator. Because of the yield statement, invoking the Cross method in the GameMoves constructor, the code you see implemented in this method will not be called - you can verify this setting breakpoints and running the application in the debugger. Instead, the yield statement creates a class implementing the interface IEnumerator. An object of this class is returned invoking the Cross method. Code:
Code:
For discussions and questions on the new book Professional C# 7 and .NET Core 2.0, please create an issue in https://github.com/ProfessionalCShar...ssionalCSharp7. For Professional C# 6 questions, you can use GitHub as well: https://github.com/ProfessionalCShar...ssionalCSharp6. |
All times are GMT -4. The time now is 07:53 PM. |
Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.