如何将列表复制到新列表,或在C#中按值检索列表 [英] how to copy a list to a new list, or retrieve list by value in c#

查看:55
本文介绍了如何将列表复制到新列表,或在C#中按值检索列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在c#中注意到有一个Lists方法: CopyTo->复制到数组,是否有更好的方法复制到新列表?问题是,我想按值检索列表,以便能够在显示项目之前删除它们,我不希望修改原始列表,这似乎也不容易实现,有什么想法吗?

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 be able to remove items before displaying them, i dont want the original list to be modified, that too doesnt seem to be easily attainable, any ideas?

推荐答案

List<MyType> copy = new List<MyType>(original);

这篇关于如何将列表复制到新列表,或在C#中按值检索列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆