Generic interfaces
Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio
Contents |
[edit]
ICollection
[edit]
IList
[edit]
IDictionary
[edit]
IComparable
[edit]
IComparer
[edit]
IEqualityComparer
[edit]
IEnumerable
[edit]
IEnumerator
IEnumerator<T> supports a type safe iteration over a generic collection. It has all the same members as IEnumerator (It "inherits" from IEnumerator), however it also has a Current property of type T. The T Current property allows retrieving the current item in the iteration without requiring a cast from object.
When implementing the generic IEnumerator, implement the nongeneric Current property explicitly:
public class MyEnumerator<T> : IEnumerator<T>{ // Implement the Generic Current implicitly // so it is always visible public T Current { get{ //... } } // Implement the nonGeneric Current explicitly // so it is only visible with a // nongeneric IEnumertor refererence public object IEnumator.Current { get{ //... } } //... }
See IEnumerator
[edit]