选择使用哪个集合时感到困惑
MSDN 用户指南要求我们不要使用 System.Collections,而是要求我们使用 System.Collection.Generic。如果它是只读集合,则应使用 System.Collections.Generic。如果集合经常被修改(添加/删除),似乎我们需要使用 System.Collections.Concurrent。问题:
查询:“Select * from sometable”;
假设我已经从表(查询)中检索了所有行,并且需要将其传递到某个将存储某个表对象的列表中,我应该使用哪种集合类型?
似乎如果我的目标是 .Net 4,那么应该使用 System.Collection.Concurrent。这是否意味着 System.Collection.Concurrent 是 System.Collection.Generic 的高级版本并旨在取代它?
多谢
MSDN User Guide asks us not to use System.Collections and instead of it asks us to use System.Collection.Generic. if it is read only collections than System.Collections.Generic should be used. if the collection is often modified( add/remove) seems like we need to use System.Collections.Concurrent. Question:
Query: "Select * from sometable";
Let's say I've retreived all rows from my table ( Query ) and need to pass it into some list which will store sometable object, Which collection type should I use?
Seems like if I am targeting .Net 4 than should use System.Collection.Concurrent. Does it mean that System.Collection.Concurrent is superior version of System.Collection.Generic and aimed to replace it?
Thanks a lot
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仅当您想从多个线程访问集合时才应使用 System.Collection.Concurrent。
否,它只包含线程安全版本。
Only if you want to access the collection from multiple threads.
No, it just contains thread-safe versions.