T in class? AddRange ICollection?

前端 未结 4 712
感动是毒
感动是毒 2021-01-12 12:07

I try to do static class, add to icollection but i got some issues i cant seem to overcome. that is how i get so i can pass a ICollection in the method? cause T is that say

4条回答
  •  轮回少年
    2021-01-12 12:31

    Depending on the collection type of your source list an alternative approach is to use List(T).ForEach, as in:

    List source = ...
    ICollection dest = ...
    
    source.Foreach(dest.Add);
    

    However, the readability of this is easy to dispute.

提交回复
热议问题