﻿<?xml version="1.0" encoding="utf-8"?><Type Name="IEnumerator&lt;T&gt;" FullName="System.Collections.Generic.IEnumerator&lt;T&gt;"><TypeSignature Language="C#" Value="public interface IEnumerator&lt;out T&gt; : IDisposable, System.Collections.IEnumerator" /><TypeSignature Language="ILAsm" Value=".class public interface auto ansi abstract IEnumerator`1&lt;+ T&gt; implements class System.Collections.IEnumerator, class System.IDisposable" /><AssemblyInfo><AssemblyName>mscorlib</AssemblyName><AssemblyVersion>2.0.0.0</AssemblyVersion><AssemblyVersion>4.0.0.0</AssemblyVersion></AssemblyInfo><TypeParameters><TypeParameter Name="T"><Constraints><ParameterAttribute>Covariant</ParameterAttribute></Constraints></TypeParameter></TypeParameters><Interfaces><Interface><InterfaceName>System.Collections.IEnumerator</InterfaceName></Interface><Interface><InterfaceName>System.IDisposable</InterfaceName></Interface></Interfaces><Docs><typeparam name="T">To be added.</typeparam><since version=".NET 2.0" /><remarks><attribution license="cc4" from="Microsoft" modified="false" /><para><see cref="T:System.Collections.Generic.IEnumerator`1" /> is the base interface for all generic enumerators.</para><para>The foreach statement of the C# language (for each in C++, For Each in Visual Basic) hides the complexity of the enumerators.  Therefore, using foreach is recommended, instead of directly manipulating the enumerator.</para><para>Enumerators can be used to read the data in the collection, but they cannot be used to modify the underlying collection.</para><para>Initially, the enumerator is positioned before the first element in the collection. At this position, <see cref="P:System.Collections.Generic.IEnumerator`1.Current" /> is undefined. Therefore, you must call <see cref="M:System.Collections.IEnumerator.MoveNext" /> to advance the enumerator to the first element of the collection before reading the value of <see cref="P:System.Collections.Generic.IEnumerator`1.Current" />.</para><para><see cref="P:System.Collections.Generic.IEnumerator`1.Current" /> returns the same object until <see cref="M:System.Collections.IEnumerator.MoveNext" /> is called. <see cref="M:System.Collections.IEnumerator.MoveNext" /> sets <see cref="P:System.Collections.Generic.IEnumerator`1.Current" /> to the next element.</para><para>If <see cref="M:System.Collections.IEnumerator.MoveNext" /> passes the end of the collection, the enumerator is positioned after the last element in the collection and <see cref="M:System.Collections.IEnumerator.MoveNext" /> returns false. When the enumerator is at this position, subsequent calls to <see cref="M:System.Collections.IEnumerator.MoveNext" /> also return false. If the last call to <see cref="M:System.Collections.IEnumerator.MoveNext" /> returned false, <see cref="P:System.Collections.Generic.IEnumerator`1.Current" /> is undefined. You cannot set <see cref="P:System.Collections.Generic.IEnumerator`1.Current" /> to the first element of the collection again; you must create a new enumerator instance instead.</para><para>The <see cref="M:System.Collections.IEnumerator.Reset" /> method is provided for COM interoperability. It does not necessarily need to be implemented; instead, the implementer can simply throw a <see cref="T:System.NotSupportedException" />.</para><para>An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and its behavior is undefined.</para><para>The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. To guarantee thread safety during enumeration, you can lock the collection during the entire enumeration. To allow the collection to be accessed by multiple threads for reading and writing, you must implement your own synchronization.</para><para>Default implementations of collections in the <see cref="N:System.Collections.Generic" /> namespace are not synchronized.</para></remarks><summary><attribution license="cc4" from="Microsoft" modified="false" /><para>Supports a simple iteration over a generic collection.</para></summary></Docs><Members><Member MemberName="Current"><MemberSignature Language="C#" Value="public T Current { get; }" /><MemberSignature Language="ILAsm" Value=".property instance !T Current" /><MemberType>Property</MemberType><AssemblyInfo><AssemblyVersion>2.0.0.0</AssemblyVersion><AssemblyVersion>4.0.0.0</AssemblyVersion></AssemblyInfo><ReturnValue><ReturnType>T</ReturnType></ReturnValue><Docs><value><para> The element in the collection over which the current instance is positioned.</para></value><since version=".NET 2.0" /><exception cref="An unspecified exception type"><para>If <see cref="M:System.Collections.IEnumerator.MoveNext" />  is not called before the first call to <see cref="P:System.Collections.Generic.IEnumerator&lt;T&gt;.Current" />.</para><para>-or-</para><para>If the previous call to <see cref="M:System.Collections.IEnumerator.MoveNext" />  returned <see langword="false" />  , indicating the end of the collection.</para></exception><remarks><attribution license="cc4" from="Microsoft" modified="false" /><para><see cref="P:System.Collections.Generic.IEnumerator`1.Current" /> is undefined under any of the following conditions:</para><list type="bullet"><item><para>The enumerator is positioned before the first element in the collection, immediately after the enumerator is created.   <see cref="M:System.Collections.IEnumerator.MoveNext" /> must be called to advance the enumerator to the first element of the collection before reading the value of <see cref="P:System.Collections.Generic.IEnumerator`1.Current" />.</para></item><item><para>The last call to <see cref="M:System.Collections.IEnumerator.MoveNext" /> returned false, which indicates the end of the collection.</para></item><item><para>The enumerator is invalidated due to changes made in the collection, such as adding, modifying, or deleting elements.</para></item></list><para><see cref="P:System.Collections.Generic.IEnumerator`1.Current" /> returns the same object until <see cref="M:System.Collections.IEnumerator.MoveNext" /> is called. <see cref="M:System.Collections.IEnumerator.MoveNext" /> sets <see cref="P:System.Collections.Generic.IEnumerator`1.Current" /> to the next element.</para></remarks><summary><attribution license="cc4" from="Microsoft" modified="false" /><para>Gets the element in the collection at the current position of the enumerator.</para></summary></Docs></Member></Members></Type>