开发者

Confusion in choosing which collection to use

开发者 https://www.devze.com 2023-02-16 11:28 出处:网络
MSDN User Guide asks us not to use System.Collec开发者_运维技巧tions and instead of it asks us to use System.Collection.Generic. if it is read only collections than System.Collections.Generic should b

MSDN User Guide asks us not to use System.Collec开发者_运维技巧tions 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


if I am targeting .Net 4 than should use System.Collection.Concurrent

Only if you want to access the collection from multiple threads.

Does it mean that System.Collection.Concurrent is superior version

No, it just contains thread-safe versions.

0

精彩评论

暂无评论...
验证码 换一张
取 消