Search code examples
c#class-designdeclarationdefinition

C# Class function members declaration & implementation


Is there a concept in C# of class definition and implementation similar to what you find in C++?

I prefer to keep my class definitions simple by removing most, if no every, implementations details (it depends on several factors as you may know, but generally I move towards leaving most member implementation details outside the class definition). This has the benefit of giving me a bird's eye view of the class and its functionality.

However in C# it seems I'm forced to define my member functions at the point of declaration. Can this be avoided, or circumvent some way?

During my apprenticeship of C#, this is one aspect that is bothering me. Classes, especially complex ones, become increasingly harder to read.


Solution

  • If you're using Visual Studio, you can take advantage of the Class View. You can also use the expand/collapse features of the source code editor.

    In the improbable case that your tools don't help, you can always write a quick utility that will summarize the class for you.

    If the class has been compiled, you can use Reflector to view the class, too.