.NET 类及其源代码
当我编写 C#(或任何 .NET 程序)时,我使用方法和类。我使用的大部分代码都是从 .NET 类调用方法。是否可以(纯粹出于好奇)查看这些类的实际源代码?
我知道 MSDN 有完整的类、它们的属性和方法的列表。但我想看看代码。
When I'm writing a C# (or any .NET programme) I use methods and classes. Most of the code I use is calling methods from the .NET classes. Is it possible (purely out of curiosity) to see the actual source code for these classes?
I know MSDN has full listings of the classes, their properties and their methods. But I would like to see the code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
是的,是:
Yes, it is:
是的,这是可能的。有关详细信息,请参阅此处:
http://weblogs.asp.net/scottgu/archive/2008/01/16/net-framework-library-source-code-now-available.aspx
Yes it is possible. See here for more info:
http://weblogs.asp.net/scottgu/archive/2008/01/16/net-framework-library-source-code-now-available.aspx
如果您不想配置开发环境,您还可以在基类库上运行反汇编程序(例如 Reflector 中的反汇编程序)并以这种方式查看代码。您不会获得真实的变量名称或注释,但对于单独查看,这可能会更容易。
You can also run a disassembler (such as the one in Reflector) over the base class libraries and view code that way, if you don't want to configure your dev environment. You won't get real variable names or comments, but for isolated viewing this can be easier.
是的,微软已经发布了.NET 源代码。
这篇文章应该可以帮助您入门。
Yes, Microsoft has released the source .NET.
This article should help get you started.
接受的答案中提到的链接(https://referencesource.microsoft.com/)仅包含.NET源代码最高版本为 4.8。开发现已在 Github 上完成,您可以在其中找到(字面上的)源文件的最新版本。
dotnet
Github 组织(.NET 基金会)拥有许多与.NET,包括core
、CLR 运行时,aspnetcore
,和其他一些人。大多数源代码都组织为 Visual Studio 项目和解决方案,因此您可以轻松导入它们。The link mentioned in the accepted answer (https://referencesource.microsoft.com/) only contains .NET source up to version 4.8. Development is now done on Github, where you can find (literally) up-to-the-minute versions of the source files.
The
dotnet
Github organization (the .NET Foundation) has many of the repos relating to .NET, includingcore
, the CLR runtime,aspnetcore
, and a bunch of others. Most of the source code is organized into Visual Studio projects and solutions, so you can import them easily.