C# Documentation

More fun features in .NET, actually this time specific to C#. Documentation, though not usually the most fun thing to write, is probably one of the most valuable. C# lets you embed your documentation in your source code as XML. Visual Studio users will be pleased to know that their IDE automatically rips out the XML and creates Microsoft MSDN style files automagically. But where does that leave those of us who hack in Notepad or Eclipse? Even better off! Enter your XML documentation (more information on XML documentation within C# below) in your source code and then add a flag to your compilation statement. Here’s a sample compile statement of a class called ‘MyClass’:

csc /t:library /r:System.dll /doc:MyClass.xml MyClass.cs

Given that you entered comments in your source code, the C# compiler will then strip our your comments, package hierarchy, related classes and create an xml file, in the above case, called ‘MyClass.xml’. In and of itself, this doesn’t do you much good. But if you download NDOC from sourceforge, you can create not only Microsoft MSDN style help files, but JavaDoc help files, LaTex helps files and plain xml.

Further Resources:
C# Programmer’s Reference: XML Documentation [msdn]
C# Programmer’s Reference: Tags for Documentation Comments: [msdn]
XML Comments Let You Build Documentation Directly From Your Visual Studio .NET Source Files [msdn mag]

This entry was posted in .NET. Bookmark the permalink.

3 Responses to C# Documentation

  1. There is also UDFDoc, a rip-off of JavaDoc for UDFs. You can download a tool at http://www.cflib.org that will generate web docs based on UDFDoc comment syntax.

  2. Naveen says:

    How to exclude some part of the documentation in C#

  3. Jared.TW says:

    Unfortunately, NDOC doesnt’ support .Net 2.0. Sombody may be interested in Sandcastle, that is created by the Microsoft development team. It’s url:http://blogs.msdn.com/sandcastle/

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>