.NET classes and their source code
When I'm writing a C# (or any .NET programme) I use methods and classes.开发者_StackOverflow社区 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.
Yes, it is:
Browse the .NET Framework source code online, with search and navigation powered by Roslyn.
See details at the .NET Framework blog...
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
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.
Yes, Microsoft has released the source .NET.
This article should help get you started.
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, including core
, 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.
精彩评论