1.<c>
<c>text</c>
which
text you want to indicate as code.
Note
The <c> tag gives you a way to mark the text in the description as code. Use <code> to indicate multiple lines as code.
Compile with/doc to process document annotations into files.
Example
Xml_c_tag.cs
Compile with:/doc:xml_c_tag.xml
Text for Class MyClass
public class MyClass
{
<summary><c>mymethod</c>is a method in The<c>myclass</c>class.
</summary>
public static void MyMethod (int Int1)
{
}
Text for Main
public static void Main ()
{
}
}
2.<para>
Please see
Suggested Document Comment tags
<para>content</para>
which
Content
The paragraph text.
Note
<para> tags are used in tags such as <summary>, <remarks>, or <returns>, allowing you to add structures to text.
Compile with/doc to process document annotations into files.
3. <see>
Please see
Suggested Document Comment tags
<see cref= "Member"/>
which
CREF = "Member"
A reference to a member or field that can be called through the current compilation environment. After the compiler checks that a given code element exists, it passes the member to the element name in the output XML. Member must be enclosed in double quotation marks ("").
Note
The <see> tag allows you to specify a link from within the text. Use <seealso> to indicate the text that you want to appear in the See Also section.
Compile with/doc to process document annotations into files.
4. <code>
Please see
Suggested Document Comment tags
<code>content</code>
which
Content
The text that you want to mark as code.
Note
The <code> tag gives you a way to indicate multiple lines as code. Use <c> to indicate that the text in the description should be marked as code.
Compile with/doc to process document annotations into files.
5. <param>
Please see
Suggested Document Comment tags
<paramname= ' name ' >description</param>
which
Name
The name of the method parameter. Enclose this name in single quotation marks (').
Description
Parameter description.
Note
The <param> tag should be used in the comments of the method declaration to describe one of the parameters of the method.
The text about the <param> tag is displayed in IntelliSense, Object Browser, and code comment Web reports.
Compile with/doc to process document annotations into files.
Example
Xml_param_tag.cs
Compile with:/doc:xml_param_tag.xml
Text for Class MyClass
public class MyClass
{
<param name= "Int1" >used toindicate status.</param>
public static void MyMethod (int Int1)
{
}
Text for Main
public static void Main ()
{
}
}
6. <seealso>
Please see
Suggested Document Comment tags
<seealso cref= "Member"/>
which
CREF = "Member"
A reference to a member or field that can be called through the current compilation environment. After the compiler checks that a given code element exists, it passes the member to the element name in the output XML. Member must be enclosed in double quotation marks ("").
Note
The <seealso> tag lets you specify the text that you want to appear in the See Also section. Use <see> to specify a link from within the text.
Compile with/doc to process document annotations into files.
7. <example>
Please see
Suggested Document Comment tags
<example>description</example>
which
Description
A description of the code sample.
Note
Use the <example> tag to specify examples that use methods or other library members. In general, this will involve the use of <code> tags.
Compile with/doc to process document annotations into files
Example
Xml_example_tag.cs
Compile with:/doc:xml_ctag.xml
Text for Class MyClass
public class MyClass
{
<summary>
The Getzero method.
</summary>
<example> This is sample shows Howto call the Getzero method.
<code>
Class MyClass
/// {
public static int Main ()
/// {
return Getzero ();
/// }
/// }
</code>
</example>
public static int Getzero ()
{
return 0;
}
Text for Main
public static void Main ()
{
}
}
8. <paramref>
Please see
Suggested Document Comment tags
<paramref name= "Name"/>
which
Name
The name of the parameter to reference. Enclose this name in double quotation marks ("").
Note
The <paramref> tag gives you a way to indicate that the word is a parameter. The XML file can be processed to format the parameter in a unique way.
Compile with/doc to process document annotations into files.
Example
Xml_paramref_tag.cs
Compile with:/doc:xml_paramref_tag.xml
Text for Class MyClass
public class MyClass
{
<remarks>mymethod is a method inthe MyClass class.
The <paramref name= "Int1"/>parameter takes a number.
</remarks>
public static void MyMethod (int Int1)
{
}
Text for Main
public static void Main ()
{
}
}
9. <summary>
Please see
Suggested Document Comment tags
<summary>description</summary>
which
Description
The summary of the object.
Note
The <summary> tag should be used to describe a type or type member. Use <remarks> to add supplemental information for a type description.
The text about the <summary> tag is the only source of type information in IntelliSense and is also displayed in the Object Browser and code comment WEB report.
Compile with/doc to process document annotations into files.
Example
Xml_summary_tag.cs
Compile with:/doc:xml_summary_tag.xml
Text for Class MyClass
public class MyClass
{
<summary>mymethod is a method inthe MyClass class.
<para>here's how to could make asecond paragraph in a description. <seecref= "System.Console.WriteLine"/> for informationabout output statements.</para>
<seealsocref= "Myclass.main"/>
</summary>
public static void MyMethod (int Int1)
{
}
Text for Main
public static void Main ()
{
}
}
<exceptioncref= "Member" >description</exception>
which
CREF = "Member"
A reference to an exception that can be obtained from the current compilation environment. After the compiler checks that a given exception exists, it converts member to the canonical element name in the output XML. Member must be enclosed in double quotation marks ("").
Description
Description
Note
The <exception> tag allows you to specify which exceptions can be raised. The tag is applied to the method definition.
Compile with/doc to process document annotations into files.
Example
Xml_exception_tag.cs
Compile with:/doc:xml_exception_tag.xml
Using System;
Comment for Class
public class Eclass:exception
{
Class definition ...
}
<exceptioncref= "System.Exception" >thrown when....</exception>
Class TestClass
{
public static void Main ()
{
Try
{
}
catch (EClass)
{
}
}
}
One. <permission>
Please see
Suggested Document Comment tags
<permissioncref= "Member" >description</permission>
which
CREF = "Member"
A reference to a member or field that can be called through the current compilation environment. After the compiler checks that a given code element exists, it converts member to the canonical element name in the output XML. Member must be enclosed in double quotation marks ("").
Description
A description of the access to the member.
Note
The <permission> tag allows you to record access to a member in a document. System.Security.PermissionSet allows you to specify access to members.
Compile with/doc to process document annotations into files.
Example
Xml_permission_tag.cs
Compile with:/doc:xml_permission_tag.xml
Using System;
Class TestClass
{
<permissioncref= "System.Security.PermissionSet" >everyone canaccess thismethod.</permission>
public static void Test ()
{
}
public static void Main ()
{
}
}
<value>
Please see
Suggested Document Comment tags
<value>property-description</value>
which
Property-description
The description of the property.
Note
The <value> tag allows you to describe properties. Note that when you add a property through the Code wizard in the VisualStudio. NET development environment, it adds a <summary> tag to the new property. Then, you should manually add the <value> tag to describe the value represented by the property.
Compile with/doc to process document annotations into files.
Example
Xml_value_tag.cs
Compile with:/doc:xml_value_tag.xml
Using System;
Text for Class Employee
public class Employee
{
private string name;
<value>name accesses the value ofthe Name data member</value>
public string Name
{
Get
{
return name;
}
Set
{
name = value;
}
}
}
Text for Class MainClass
public class MainClass
{
Text for Main
public static void Main ()
{
}
}
<include>
Please see
Suggested Document Comment tags
<include file= ' filename ' path= ' tagpath[@name = "id"] '/>
which
FileName
Contains the file name of the document. The file name can be qualified with a path. Enclose the filename in single quotation marks (' ').
Tagpath
The tag path in filename that points to the tag name. Enclose this path in single quotation marks (').
Name
The name specifier in the tag in front of the comment; the name has an ID.
Id
The ID of the tag that precedes the comment. Enclose this ID in double quotation marks ("").
Note
The <include> tag enables you to reference comments in another file that describes the types and members in the source code. This is an alternative way to put the document comment directly outside of the source code file.
The <include> tag uses XML XPath syntax. For methods of customizing <include> using, see the XPath documentation.
Example
The following is a multi-file example. The first file uses <include>, as listed below:
Xml_include_tag.cs
Compile with:/doc:xml_include_tag.xml
<include file= ' xml_include_tag.doc ' path= ' mydocs/mymembers[@name = "test"]/* '/>
Class Test
{
public static void Main ()
{
}
}
<include file= ' xml_include_tag.doc ' path= ' mydocs/mymembers[@name = "test2"]/* '/>
Class Test2
{
public void Test ()
{
}
}
The second file Xml_include_tag.doc contains the following document comments:
<MyDocs>
<mymembers name= "Test" >
<summary>
The summary for this type.
</summary>
</MyMembers>
<mymembers name= "Test2" >
<summary>
The summary for this and other type.
</summary>
</MyMembers>
</MyDocs>
Program output
<?xml version= "1.0"?>
<doc>
<assembly>
<name>t2</name>
</assembly>
<members>
<member name= "T:test" >
<summary>
The summary for this type.
</summary>
</member>
<member name= "T:test2" >
<summary>
The summary for this and other type.
</summary>
</member>
</members>
</doc>
<remarks>
Please see
Suggested Document Comment tags
<remarks>description</remarks>
which
Description
The description of the member.
Note
The <remarks> tag is used to add information about a type, supplementing the information specified by <summary>. This information is displayed in the Object Browser and in the Code Comment Web report.
Compile with/doc to process document annotations into files.
Example
Xml_remarks_tag.cs
Compile with:/doc:xml_remarks_tag.xml
<summary>
You may have some primary information on this class.
</summary>
<remarks>
Some additional information about ThisClass.
</remarks>
public class MyClass
{
Text for Main
public static void Main ()
{
}
}
<list>.
Please see
Suggested Document Comment tags
<list type= "Bullet" | "Number" | " Table ">
<listheader>
<term>term</term>
<description>description</description>
</listheader>
<item>
<term>term</term>
<description>description</description>
</item>
</list>
which
Term
The item to be defined, which is defined in text.
Description
The definition of an item or term in a bulleted or numbered list.
Note
<listheader> blocks are used to define header rows in a table or definition list. When you define a table, you only need to provide an item for the item in the header.
Each item in the list is specified with a <item> block. When you create a definition list, you need to specify both the term and text. However, for a table, bulleted list, or numbered list, you only need to provide an entry for text.
The number of <item> blocks that a list or table can have depends on your needs.
Compile with/doc to process document annotations into files.
Example
Xml_list_tag.cs
Compile with:/doc:xml_list_tag.xml
Text for Class MyClass
public class MyClass
{
<remarks>here is an example of abulleted list:
<list type= "Bullet" >
<item>
<description>Item1.</description>
</item>
<item>
<description>Item2.</description>
</item>
</list>
</remarks>
public static void Main ()
{
}
}
<returns>
Please see
Suggested Document Comment tags
<returns>description</returns>
which
Description
A description of the return value.
Note
The <returns> tag should be used as a comment for the method declaration to describe the return value.
Compile with/doc to process document annotations into files.
Example
Xml_returns_tag.cs
Compile with:/doc:xml_returns_tag.xml
Text for Class MyClass
public class MyClass
{
<returns>Returnszero.</returns>
public static int Getzero ()
{
return 0;
}
Text for Main
public static void Main ()
{
}
}
Reprinted from: http://hi.baidu.com/hopeforeverwyj/blog/item/a4c5024f989fe736aec3ab75.html
VS XML annotations