public bool MoveNext()
        {
            this.currentIndex++;

            DebuggingTool.DebugMsg($"ArrayEnumerator<T> :: MoveNext :: NewIndex={this.currentIndex}");

            return(this.currentIndex <= this.endIndex);
        }
        // non-generic enumerators

        private IEnumerator GetNongenericEnumerator_UsingForeach()
        {
            // Magic happens here!!
            DebuggingTool.DebugMsg($"CustomEnumeration<T> :: Called GetEnumerator (non-generic)");

            foreach (object item in this.backingArray)
            {
                DebuggingTool.DebugMsg($"CustomEnumeration<T> :: New foreach iteration (non-generic) :: current element is {item}");

                yield return(item);
            }
        }
Ejemplo n.º 3
0
        private IEnumerator GetEnumerator_UsingForeach()
        {
            // Magic happens here!!
            DebuggingTool.DebugMsg($"CustomEnumeration :: Called GetEnumerator");

            foreach (var item in this.backingArray)
            {
                DebuggingTool.DebugMsg($"CustomEnumeration :: New foreach iteration :: current element is {item}");

                yield return(item);
            }
        }
        public void Reset()
        {
            this.currentIndex = -1;

            DebuggingTool.DebugMsg($"ArrayEnumerator<T> :: Reset :: NewIndex={this.currentIndex}");
        }