joining IEnumerables together

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cody

    joining IEnumerables together

    Hi, I have multiple Collections which I want to iterate over *without*
    copying alle my collections into one.

    If there is no method to do this I propose a new Class Enumerate which
    should provide something like that: IEnumerable Join(IEnumerabl e
    a,IEnumerable b)


  • Jon Skeet [C# MVP]

    #2
    Re: joining IEnumerables together

    cody <deutronium@gmx .de> wrote:[color=blue]
    > Hi, I have multiple Collections which I want to iterate over *without*
    > copying alle my collections into one.
    >
    > If there is no method to do this I propose a new Class Enumerate which
    > should provide something like that: IEnumerable Join(IEnumerabl e
    > a,IEnumerable b)[/color]

    That's very easy to write - I suggest you try it and see how useful it
    is for you.

    --
    Jon Skeet - <skeet@pobox.co m>
    Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

    If replying to the group, please do not mail me too

    Comment

    • cody

      #3
      Re: joining IEnumerables together

      Yes writing that kind of functionality is not a problem but it would be
      great if the framework would provide such a thing, just because I don't like
      always having to reinvent the wheel.


      "Jon Skeet [C# MVP]" <skeet@pobox.co m> schrieb im Newsbeitrag
      news:MPG.1d2a3e 6d3426fe3198c3b e@msnews.micros oft.com...[color=blue]
      > cody <deutronium@gmx .de> wrote:[color=green]
      >> Hi, I have multiple Collections which I want to iterate over *without*
      >> copying alle my collections into one.
      >>
      >> If there is no method to do this I propose a new Class Enumerate which
      >> should provide something like that: IEnumerable Join(IEnumerabl e
      >> a,IEnumerable b)[/color]
      >
      > That's very easy to write - I suggest you try it and see how useful it
      > is for you.
      >
      > --
      > Jon Skeet - <skeet@pobox.co m>
      > http://www.pobox.com/~skeet
      > If replying to the group, please do not mail me too[/color]


      Comment

      • Ted Miller

        #4
        Re: joining IEnumerables together

        In 2.0 this becomes trivial:

        public IEnumerable<T> JoinTwoEnumerat ors(IEnumerable <T> first,
        IEnumerable<T> second)
        {
        foreach (T t in first)
        {
        yield return t;
        }

        foreach (T t in second)
        {
        yield return t;
        }
        }


        "cody" <deutronium@gmx .de> wrote in message
        news:eIs4YxzeFH A.1504@TK2MSFTN GP15.phx.gbl...[color=blue]
        > Yes writing that kind of functionality is not a problem but it would be
        > great if the framework would provide such a thing, just because I don't
        > like always having to reinvent the wheel.
        >
        >
        > "Jon Skeet [C# MVP]" <skeet@pobox.co m> schrieb im Newsbeitrag
        > news:MPG.1d2a3e 6d3426fe3198c3b e@msnews.micros oft.com...[color=green]
        >> cody <deutronium@gmx .de> wrote:[color=darkred]
        >>> Hi, I have multiple Collections which I want to iterate over *without*
        >>> copying alle my collections into one.
        >>>
        >>> If there is no method to do this I propose a new Class Enumerate which
        >>> should provide something like that: IEnumerable Join(IEnumerabl e
        >>> a,IEnumerable b)[/color]
        >>
        >> That's very easy to write - I suggest you try it and see how useful it
        >> is for you.
        >>
        >> --
        >> Jon Skeet - <skeet@pobox.co m>
        >> http://www.pobox.com/~skeet
        >> If replying to the group, please do not mail me too[/color]
        >
        >[/color]


        Comment

        • Helge Jensen

          #5
          Re: joining IEnumerables together


          public IEnumerable<T> JoinEnumerators (params IEnumerable<T>[] enums) {
          foreach ( IEnumerator enum in enums )
          foreach ( T t in enum )
          yield return t;
          }

          --
          Helge Jensen
          mailto:helge.je nsen@slog.dk
          sip:helge.jense n@slog.dk
          -=> Sebastian cover-music: http://ungdomshus.nu <=-

          Comment

          • Helge Jensen

            #6
            Re: joining IEnumerables together


            public IEnumerable<T> JoinEnumerators (params IEnumerable<T>[] enums) {
            foreach ( IEnumerator enum in enums )
            foreach ( T t in enum )
            yield return t;
            }

            --
            Helge Jensen
            mailto:helge.je nsen@slog.dk
            sip:helge.jense n@slog.dk
            -=> Sebastian cover-music: http://ungdomshus.nu <=-

            Comment

            Working...