ienumerator Questions

10

Solved

I have some coroutines: IEnumerator a(){ /* code */ } IEnumerator b(){ /* code */ } IEnumerator c(){ /* code */ } I want to create a coroutine that calls a, b and c in parallel but wait for all ...
Colley asked 15/12, 2019 at 22:13

8

Solved

In C#, how does one obtain a generic enumerator from a given array? In the code below, MyArray is an array of MyType objects. I'd like to obtain MyIEnumerator in the fashion shown, but it seems th...
Quotient asked 13/8, 2009 at 15:21

1

Solved

Why next code generates loop hangs? var x = new { Items = new List<int> { 1, 2, 3 }.GetEnumerator() }; while (x.Items.MoveNext()) Console.WriteLine(x.Items.Current); If I get enumerator a...
Candelabra asked 27/1, 2023 at 11:23

3

Solved

I'm currently trying to understand IEnumerator & Coroutine within the context of Unity and am not too confident on what the "yield return null" performs. At the moment i believe it basically pa...
Wicked asked 18/1, 2017 at 13:5

6

Solved

Below is a simple example of the difference I would like to highlight. Using coroutines: public float repeatRate = 5f; void Start() { StartCoroutine("RepeatSomething"); } IEnumerator RepeatSomet...
Succedaneum asked 27/4, 2020 at 17:13

6

Solved

There is the command hierarchy in my current application. public interface ICommand { void Execute(); } So, some commands are stateful, some are not. I need to enumerate IEnumerable in the circul...
Scene asked 22/5, 2012 at 5:57

6

Solved

I have IEnumerable collection like following IEnumerable<Customer> items = new Customer[] { new Customer { Name = "test1", Id = 999 }, new Customer { Name = "test2", Id = 989 } }; I...
Nessie asked 24/8, 2015 at 7:7

6

Solved

With Java Iterators, I have used the hasNext method to determine whether an iteration has more elements (without consuming an element) -- thus, hasNext is like a "Peek" method. My question: is the...
Conjurer asked 13/8, 2009 at 16:13

7

Solved

I use the following code to enable myClass to use foreach. But I am rather new to programming and have some difficulty in understanding the following code. I described my problems in the comments. ...
Ecclesiasticism asked 28/12, 2010 at 18:38

1

Solved

Since the release of C# 8.0, I've really been enjoying the 'void safety' with nullable reference types. However, while tweaking a library of mine to support the new feature, I stumbled upon a 'prob...
Frisco asked 14/10, 2019 at 7:38

16

Solved

Can anyone explain IEnumerable and IEnumerator to me? For example, when to use it over foreach? what's the difference between IEnumerable and IEnumerator? Why do we need to use it?
Farflung asked 17/2, 2009 at 19:11

1

Solved

I want to understand how chain query is processed. For example, let us consider the following query var sumOfRoots = numbers //IEnum0 .Where(x => x > 0) //IEnum1 .Select(x => Math.Sqrt(...
Ptolemaic asked 9/8, 2018 at 10:10

9

Solved

I have an interface that, among other things, implements a "public IEnumerator GetEnumerator()" method, so I can use the interface in a foreach statement. I implement this interface in several cla...
Barley asked 11/11, 2009 at 10:35

2

Solved

It is quite a while that I have been trying to understand the idea behind IEnumerable and IEnumerator. I read all the questions and answers I could find over the net, and on StackOverflow in partic...
Genvieve asked 31/3, 2017 at 8:2

2

Solved

I'm new and a bit confused about "yield". But finally I understand how it worked using WaitForSeconds but I can't see the difference between of "yield return 0" and "yield return null". are both...
Cretinism asked 1/9, 2016 at 10:12

2

Solved

I was implementing my own ArrayList class and was left surprised when I realised that public System.Collections.Generic.IEnumerator<T> GetEnumerator() { return _array.GetEnumerator(); } d...
Marquetry asked 5/5, 2010 at 13:47

5

Solved

I am trying to implement IEnumerable<Turtle> in a class deriving from a base class that already implements IEnumerable<Animal>. Why will calling base.Cast<Turtle>() (or any LINQ...
Firebrat asked 29/1, 2016 at 11:21

5

Solved

I am writing a custom ConfigurationElementCollection for a custom ConfigurationHandler in C#.NET 3.5 and I am wanting to expose the IEnumerator as a generic IEnumerator. What would be the best way...
Odel asked 6/5, 2009 at 6:54

4

I have been debugging this production bug for sometime and I'm desperate for help and also it's interesting to me. I have simplified the code logic and added some print-out for debugging: int[] a...
Cheery asked 23/4, 2015 at 9:21

7

Solved

Is there a way to use yield blocks to implement an IEnumerator<T> which can go backward (MoveLast()) as well as forward?
Bornie asked 16/1, 2009 at 16:46

3

Solved

Looking at this code : public class myWords : IEnumerable<string> { string[] f = "I love you".Split(new string[]{"lo"},StringSplitOptions.RemoveEmptyEntries); public IEnumerator<strin...
Stipitate asked 16/2, 2013 at 10:34

5

Solved

Ok so I was just working through the IEnumerator and IEnumerable. Now the MSDN says that the main objective of these things is to iterate through a customer collection. Fair enough I was however a...
Pleistocene asked 16/12, 2012 at 14:36

2

Solved

In the framework classes of collections I have often seen IEnumerator<T> separately implemented as an inner class and an instance of it is returned in the GetEnumerator method. Now suppose ...
Heyman asked 10/6, 2014 at 13:41

2

Solved

Let's say you wrote a custom enumerator for the code below: public class School : IEnumerable<Student> And then in the client code, you did this: static void Main(string[] args) { var sc...
Prelude asked 9/5, 2014 at 20:55

5

Solved

I have a class that map objects to objects, but unlike dictionary it maps them both ways. I am now trying to implement a custom IEnumerator interface that iterates through the values. public class ...
Acro asked 10/9, 2008 at 13:5

© 2022 - 2024 — McMap. All rights reserved.