CodeTV.HashtableSerializationProxy.this C# (CSharp) Method

this() public method

public this ( int index ) : DictionaryEntry
index int
return System.Collections.DictionaryEntry
        public DictionaryEntry this[int index]
        {
            get
            {
                if (_enumerator == null)  // lazy initialization
                    _enumerator = _hashTable.GetEnumerator();

                // Accessing an item that is before the current position is something that
                // shouldn't normally happen because XmlSerializer calls indexer with a constantly
                // increasing index that starts from zero.
                // Trying to go backward requires the reset of the enumerator, followed by appropriate
                // number of increments. (Enumerator acts as a forward-only iterator.)
                if (index < _position)
                {
                    _enumerator.Reset();
                    _position = -1;
                }

                while (_position < index)
                {
                    _enumerator.MoveNext();
                    _position++;
                }
                return _enumerator.Entry;
            }
        }