Created
February 27, 2022 18:44
-
-
Save sebastienros/0d685e74b0522c8dc3990a499d40a47c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
public class MyCollection<T> : IEnumerable<T> | |
{ | |
private readonly List<T> _collection = new List<T>(); | |
public IEnumerator<T> GetEnumerator() => _collection.GetEnumerator(); | |
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); | |
} | |
/* | |
error CS0305: Using the generic type 'IEnumerable<T>' requires 1 type arguments | |
error CS0305: Using the generic type 'IEnumerator<T>' requires 1 type arguments | |
error CS0538: 'IEnumerable' in explicit interface declaration is not an interface | |
error CS0738: 'MyCollection<T>' does not implement interface member 'IEnumerable.GetEnumerator()'. 'MyCollection<T>.GetEnumerator()' cannot implement 'IEnumerable.GetEnumerator()' because it does not have the matching return type of 'IEnumerator'. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment