Skip to Main Content
Programming C#
book

Programming C#

by Jesse Liberty
July 2001
Intermediate to advanced content levelIntermediate to advanced
688 pages
16h 14m
English
O'Reilly Media, Inc.
Content preview from Programming C#

XML Documentation Comments

C# supports a new Documentation Comment style, with three slash marks (///). You can see these comments sprinkled throughout Example 13-3. The Visual Studio.NET editor recognizes these comments and helps format them properly.

The C# compiler processes these comments into an XML file. You can create this file by using the /doc command-line switch. For example, you might compile the program in Example 13-3 with this command line:

csc filecopier.cs /r:System.Windows.Forms.dll /r:mscorlib.dll 
/r:system.dll /r:system.configuration.dll /r:system.data.dll 
/r:system.diagnostics.dll /r:system.drawing.dll /r:microsoft.win32.interop.dll 
/doc:XMLDoc.XML

You can accomplish this same operation in Visual Studio .NET by clicking a project icon in the Solution Explorer window, selecting View Property Pages on the Visual Studio menu, and then clicking the Configuration Properties folder. Within the Configuration Properties folder, click the Build property page and type in a name for the XML Documentation File property to specify a name for the XML file you want to produce.

Either approach produces the file XMLDoc.XML with your comments in XML format. An excerpt of the file that will be produced for the FileCopier application of the previous section is shown in Example 13-4.

Example 13-4. The XML output (excerpt) for file copy

<?xml version="1.0"?> <doc> <assembly> <name>FileCopier</name> </assembly> <members> <member name="T:FileCopier.Form1"> <summary> Form demonstrating ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming C#, Second Edition

Programming C#, Second Edition

Jesse Liberty
Programming C# 12

Programming C# 12

Ian Griffiths
Programming C# 8.0

Programming C# 8.0

Ian Griffiths

Publisher Resources

ISBN: 0596001177Supplemental ContentCatalog PageErrata