Method in ICollection in C# that adds all elements of another ICollection to it

Posted by drasto on Stack Overflow See other posts from Stack Overflow or by drasto
Published on 2010-06-06T14:53:49Z Indexed on 2010/06/06 15:02 UTC
Read the original article Hit count: 457

Filed under:
|

Is there some method in ICollection in C# that would add all elements of another collection? Right now I have to always write foreach cycle for this:

ICollection<Letter> allLetters = ... //some initalization
ICollection<Letter> justWrittenLetters = ... //some initalization
... //some code, adding to elements to those ICollections

foreach(Letter newLetter in justWrittenLetters){
    allLetters.add(newLetter);
}

My question is, is there method that can replace that cycle? Like for example the method addAll(Collection c) in Java ? So I would write only something like:

allLetters.addAll(justWrittenLetters);

© Stack Overflow or respective owner

Related posts about c#

Related posts about collections