var mc = new MyClass(5); foreach(var item in mc) {
}
classMyClass : IEnumerator { int length; publicMyClass(int length) { this.length = length; } public IEnumerator GetEnumerator() { for (int i = 0; i < length; i++) { yieldreturn i.ToString(); } } } // var mc = new MyClass(5); foreach(var item in mc) {
}
classMyClass { int length; publicMyClass(int length) { this.length = length; } public IEnumerator GetEnumerator() { for (int i = 0; i < length; i++) { yieldreturn i.ToString(); } } } // foreach(var item in5) {
} publicclassMyExtensions { publicstatic IEnumerator GetEnumerator(thisint count) { for (int i = 0; i < count; i++) { yieldreturn i.ToString(); } } }