Is there a C # equivalent for an STL output iterator?

I am looking for some type of iterator / enumerator that can write to a support collection. As I understand it, C # enums are read-only.

+5
source share
3 answers

In C #, nothing exists to do such a thing.

You are correct IEnumerator The current property is determined as soon as the recipient.

You will need to write a new class and / or interface to support such a thing.

interface IOutputable<T> {
  IOutputer<T> GetOutputer();
  }

interface IOutputer<T> {

  T Current { set; }

  bool MoveNext();
  void Reset();
  }
+2
source

AFAIK - - . # . , Stack. / ++ push:

var sequence = new Stack<int>();
sequence.Push( 1 );
sequence.Push( 2 );

, #.

+2

Depending on what you are trying to do, it yield returnmay do what you are looking for.

0
source

All Articles