Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/264.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 什么';.NET中System.Collections、System.Collections.Specialized和System.Collections.Generic之间的区别是什么?_C#_.net_Data Structures_Key Value - Fatal编程技术网

C# 什么';.NET中System.Collections、System.Collections.Specialized和System.Collections.Generic之间的区别是什么?

C# 什么';.NET中System.Collections、System.Collections.Specialized和System.Collections.Generic之间的区别是什么?,c#,.net,data-structures,key-value,C#,.net,Data Structures,Key Value,三者之间的主要区别是什么?现在,我想分别使用string/string创建一个键/值对。这三个似乎都有我可以使用的选项 编辑:我只想创建一个简单的哈希表-没有什么真正复杂的东西。通用集合几乎完全取代了基本集合和集合。专用。要真正给出最好的推荐,我们需要更多地了解您想要做什么,但很可能您想要System.Collections.Generic.Dictionary System.Collections:存储对System.Object类型的引用的容器 System.Collections.Spe

三者之间的主要区别是什么?现在,我想分别使用string/string创建一个键/值对。这三个似乎都有我可以使用的选项


编辑:我只想创建一个简单的哈希表-没有什么真正复杂的东西。

通用集合几乎完全取代了基本集合和集合。专用。要真正给出最好的推荐,我们需要更多地了解您想要做什么,但很可能您想要
System.Collections.Generic.Dictionary

  • System.Collections
    :存储对
    System.Object
    类型的引用的容器
  • System.Collections.Specialized
    :非
    System.Object
    类型的
    System.Collections
    的专门版本(每个专门化都有不同的集合类型,每个存储在程序集中)
  • System.Collections.Generic
    :上述两种的替换,因为运行时将确定如何为要存储在其中的类型创建集合(一种集合类型用于所有专门化)

答案在很大程度上取决于您的使用情况。在不了解详细信息的情况下,我会说查看字符串的System.Collections.Specialized.NameValueCollection,string。System.Collections.Specialized和System.Collections.Generic是强类型的,我认为System.Collections只是.NET 1.1留下的。

Dictionary>NameValueCollections我几乎不敢相信这是一个真正的问题。这是三个名称空间。显然,不同之处在于名称空间中的名称!这真的是你要问的吗?只是一个随机的提示:System.Collections.Generic.List是用数组实现的。