Friday, April 29, 2011

How to view code for classes in the .NET library?

I would like to look at the code for some of the classes in the .NET library. I find functions by using intellisense and just reading the tooltips that come up when I select different items.

One example is the Contains method that you can use on arrays to search for a given string. I just happened to stumble upon that while working on an exercise to learn. I'm assuming it's a simple method that just iterates through the array and checks for the string at each element.

If I wanted to take a look at this code, or code for any other class in .NET, how would I go about it? I have Visual Studio 2008.

From stackoverflow
  • Use .NET Reflector

    Lucero : The one and only answer... basically ;)
    Mehrdad Afshari : @Lucero: Not the only...
    Lucero : Well, since the question asks for "code for any other class in .NET", the framework symbols or source will not help much. Also, looking at Rotor sources can be misleading since the actual BCL implementation may differ.
    Stevo3000 : Can't beat this answer!
  • Reflector is the way to go.

    .NET Framework 3.5 BCL source code is available through debug symbols (reference license).

    SSCLI (Rotor) and Mono source code can be relevant too.

  • Either Reflector (for ease of use and universal application) or Microsoft's symbol server for the real thing.

0 comments:

Post a Comment