T in class? AddRange ICollection?

前端 未结 4 724
感动是毒
感动是毒 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:26

    If I understand correctly you want to add a IEnumerable to an empty collection.

    Wouldn't it be easier to just do:

    ICollection collection = new List(GetIEnumerableOfMyObject());
    

    Or even:

    ICollection collection = GetIEnumerableOfMyObject().ToList();
    

提交回复
热议问题