加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – DictionaryBase和Dictionary之间的差异

发布时间:2020-12-15 08:12:50 所属栏目:百科 来源:网络整理
导读:任何人都可以告诉我DictionaryBase和通用词典 TKey,TValue之间的区别,除了DictionaryBase是一个抽象类!它们都是强类型的,我在某处读到泛型类在性能上优于非泛型类,应该是首选,那么DictionaryBase的确切用法是什么呢? 这两个课程几乎相同! 任何形式的帮助
任何人都可以告诉我DictionaryBase和通用词典< TKey,TValue>之间的区别,除了DictionaryBase是一个抽象类!它们都是强类型的,我在某处读到泛型类在性能上优于非泛型类,应该是首选,那么DictionaryBase的确切用法是什么呢?
这两个课程几乎相同!

任何形式的帮助将不胜感激

谢谢

解决方法

Dictionarybase是实现非通用IDictionary接口的基类,而Dictionary是实现通用IDictionary接口的字典的通用版本.使用仿制药比非仿制药更受欢迎.

我认为这会更有帮助When to use generics?

Using generic collections is generally recommended,because you gain
the immediate benefit of type safety without having to derive from a
base collection type and implement type-specific members. Generic
collection types also generally perform better than the corresponding
nongeneric collection types (and better than types that are derived
from nongeneric base collection types) when the collection elements
are value types,because with generics there is no need to box the
elements.

也是经过,Introduction to Generics

Generic classes and methods combine reusability,type safety and efficiency in a way that their non-generic counterparts cannot. Generics are most frequently used with collections and the methods that operate on them. Version 2.0 of the .NET Framework class library provides a new namespace,System.Collections.Generic,which contains several new generic-based collection classes. It is recommended that all applications that target the .NET Framework 2.0 and later use the new generic collection classes instead of the older non-generic counterparts

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读