11

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.

5 Answers 5

20

Yes, it is:

Browse the .NET Framework source code online, with search and navigation powered by Roslyn.

See details at the .NET Framework blog...

Sign up to request clarification or add additional context in comments.

1 Comment

Unfortunately, as of Jan 2022 this is still .NET 4.8.
3

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

Comments

3

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.

Comments

0

Yes, Microsoft has released the source .NET.

This article should help get you started.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.