XML Comments in C#
Author: James Foster | Date Posted: 09/02/2001 | .NET Version: 1.0.3705 |
Many of you have heard of JavaDoc, a feature of Java that automatically generates HTML documentation for your code. C#, and the C# compiler, is capable of a similar function, yet produces XML instead of directly producing HTML. This makes the documentation much more flexible.
Commenting Syntax To use the XML commenting features of C#, you begin by commenting your source code using the special comment syntax, /// (three slashes). After the slashes you use one of the predefined tags for documentation comments, or embed your own. Your custom xml tags will carry over into the result XML documentation.
Example The following example adds comments to our introductory HelloWorld console application. using System; namespace HelloWorld { ????/// <summary> ????/// Sample Hello World in C# ????/// </summary> ????publicclass HelloWorld ????{ ????????/// <summary> ????????/// Console Application Entry Point ????????/// <param name="args">Command Line Arguments</param> ????????/// <returns>Status code of 0 on successful run</returns> ????????/// </summary> ????????publicstaticint Main(string[]args) ????????{ ????????????System.Console.WriteLine("HelloWorld"); ????????????stringname= System.Console.ReadLine(); ????????????return(0); ????????} ????} } To get the resulting XML Documentation file, we call the csc compiler with the /doc option. csc /doc:HelloWorld.xml helloworld.cs 或修改工程的property.build.output.xmldocument.(在2005中) HTML Web Pages ![]() |
可以把xml制作chm的工具
NANT? 下載:http://nant.sourceforge.net/
NDOC? 下載:http://ndoc.sourceforge.net/
posted on 2006-04-13 14:02 夢在天涯 閱讀(830) 評論(1) 編輯 收藏 引用 所屬分類: C#/.NET