how to copy a list to a new list, or retrieve list by value in c#

后端 未结 7 2126
死守一世寂寞
死守一世寂寞 2021-01-03 22:06

I noticed in c# there is a method for Lists: CopyTo -> that copies to arrays, is there a nicer way to copy to a new list? problem is, I want to retrieve the list by value to

7条回答
  •  盖世英雄少女心
    2021-01-03 22:56

    It seems if you have a list of references, the list

    List list2 = new List(list1);
    
    

    does not work.

    This should solve your problem:

    How do I clone a generic list in C#?

    提交回复
    热议问题