什么是学习的.NET泛型集合的实施细节有很大的资源?很大、细节、资源、NET

2023-09-03 20:59:45 作者:〃金牌凯子

我有兴趣了解在.NET泛型集合的底层实现细节。我想到的是细节,比如如何集合被存储,怎一个集合中的每个成员由CLR等访问

I'm interested in understanding the underlying implementation details of generic collections in .NET. What I have in mind are details such as how the collections are stored, how each member of a collection is accessed by the CLR, etc.

有关的集合,类似于传统的数据结构,如链表和字典,我想我有下面发生了什么事情的理解。不过,我并不像某些有关集合像列表(如何设置,使得它既是可转位和可扩展?)和排序列表,因此任何线索,以什么我可以查找更多地了解他们的将是极大的AP preciated。

For collections that are analogous to traditional data structures, such as LinkedList and Dictionary, I think I have an understanding of what's going on underneath. However, I'm not as certain about collections like List (how is set up such that it is both indexable and expandable?) and SortedList, so any leads as to what I could look up to learn more about them would be greatly appreciated.

推荐答案

一个伟大的方式开始着眼于实现细节是开放的反光和反编译原始出处code。你可以反编译源$ C ​​$ C到C#或VB,并分析了code依赖。不利的一面是,反射不能产生易于读取优化code和枚举(这是一个集合实施的重要组成部分)code。

A great way to start looking at the implementation details is opening up Reflector and decompiling the original source code. You can decompile the source code to C# or VB and also analyze dependencies in the code. A downside is that Reflector isn't able to produce easy to read code from optimized code and enumerators (which are an important part of a collections implementation).

微软还发布了原始的源$ C ​​$ C,这并另外提供所有的原始意见和视野开阔的变量名。请参见这里如何启用它。你需要写一个小演示程序,使Visual Studio中下载正确的来源,但随后他们会被缓存在某些文件夹,这样您可以将它们在调试器外部容易地访问。另一种选择是使用一些工具,下载完整的来源。我认为有一个MSDN下载的来源了。

Microsoft has also released the original source code, which does additionally provide all the original comments and unobscured variable names. See here how to enable it. You'll need to write a small demo program to make Visual Studio download the right sources, but then they'll be cached in some folder so you can easily access them outside the debugger. Another option would be to use some tool that downloads the complete sources. I think there was an MSDN Download with the sources too.

您可能想看看另一件事情是如何仿制药的实际工作。他们是在其上集合构建的基础。相比于Java中,.NET实现优越,因为它允许值类型的集合而不采取降低性能。我已经写了博客文章这个主题,所以你可能要签出或阅读微软官方文件直接。

Another thing you might want to have a look at is how generics actually work. They're the basics on which the collections are built. Compared to Java, the .NET implementation is superior because it allows collections of value types without taking a performance hit. I have written a blog post on this topic, so you might want to check out that or read the official Microsoft Paper directly.

 
精彩推荐
图片推荐