|
C# 2008 Programmer's ReferenceBorrowing the popular "clean as you go" phrase found in a lot of kitchens, the best way to churn out top-quality documentation for your project is to document as you go. In Visual Studio 2008, you can document your code using the XML code documentation feature. This appendix shows you how to generate MSDN-style documentation for your project using Visual Studio 2008 and a third-party documentation generation tool — Sandcastle. Inline Documentation using XML To see how XML documentation works, create a new class library project in Visual Studio 2008 as shown in Figure C-1. Name the project PointClass. Figure C-1 Populate the default Class1.cs with the following class definition: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace PointClass { public class Point { //---static variable--- private static int count; //---properties--- public int x { get; set; } public int y { get; set; } //---constructors--- public Point() { count++; } public Point(int x, int y) { this.x = x; this.y = y; count++; } //---overloaded methods--- public double Length() { return Math.Sqrt( Math.Pow(this.x, 2) + Math.Pow(this.y, 2)); } public double Length(Point pt) { return Math.Sqrt( Math.Pow(this.x - pt.x, 2) + Math.Pow(this.y - pt.y, 2)); } } } The definition for the Point class contains the following members: ? A static private member named count ? Two properties — x and y ? Two overloaded constructors ? Two overloaded Length() methods To add XML comments to the class, type three slash (/) character in succession: /// ...» | Код для вставки книги в блог HTML
phpBB
текст
|
|