Documentation comments are designed to make it easier for you and others to understand the functionality that your code implements. Some common document comment tags are documented below:
<C>
Usage: <c>text</c>
Mark the text in the description as code. For example:
/// <summary>///validates the user./// </summary>/// <param name= "username" >The username.</param>/// <param name= "password" >The password.</param>/// <returns>/// <c>true</c>, if username and password are equal./// </returns> Public BOOLValidateUser (stringUsernamestringpassword) { varUserId =getuseridifvalid (username, password); returnUserid.hasvalue && Userid.value! =Guid.Empty;}
<code>
Usage: <code>content</code>
Mark multiple lines of text as code.
<see>
Usage: <see cref="member"/>
Used to specify the link from the text. For example:
/// <summary> /// <see cref= "Defaultauthenticationservice"/> class. /// </summary> /// <param name= "Repository" > The repository. </param> Public Defaultauthenticationservice (irepository repository) { this. Repository= Repository;}
<example>
Usage: <example>description</example>
Used to specify an example of using a method or other library member. For example:
/// <summary>///The Getzero method./// </summary>/// <example> ///This is the sample shows how to call the<see cref= "Getzero"/>method./// <code>///class TestClass/// {///static int Main ()/// {///return Getzero ();/// }/// }/// </code>/// </example> Public Static intGetzero () {return 0;}
View Code<param>
Usage: <param name="name">description</param>
A parameter used to describe the method.
<paramref>
Usage: <paramref name="name"/>
Used to reference a parameter. For example:
/// <summary>///Gets A collection of membership users where the user name contains the specified user name to match./// </summary>/// <param name= "usernameToMatch" >The user name to search for.</param>/// <param name= "PageIndex" >The index of the page of results to return.<paramref name= "PageIndex"/>is zero-based.</param>/// <param name= "PageSize" >The size of the page of results to return.</param>/// <param name= "totalrecords" >The total number of matched users.</param>/// <returns>///A<see cref= "T:System.Web.Security.MembershipUserCollection"/>collection that contains a page of<paramref name= "pageSize"/><see cref= "T:System.Web.Security.MembershipUser"/>objects beginning at the page specified by<paramref name= "PageIndex"/>./// </returns> PublicIlist<user> FindUsersByName (stringusernameToMatch,intPageIndex,intPageSize, out inttotalrecords) { returnGetusers (PageIndex, PageSize, outtotalrecords, U =u.username.contains (usernameToMatch));}
<returns>
Usage: <returns>description</returns>
Used to describe the return value.
<summary>
Usage: <summary>description</summary>
Used to describe a type or type member.
<typeparam>
Usage: <typeparam name="name">description</typeparam>
Used to describe a type parameter in a comment in a generic type or method declaration . For example:
/// <summary>///creates a new array of arbitrary type<typeparamref name= "T"/>/// </summary>/// <typeparam name= "T" >The element type of the array</typeparam>
<param name= "n" ></param>
<returns></returns> Public StaticT[] Mkarray<t> (intN) { return Newt[n];}
<typeparamref>
Usage: <typeparamref name="name"/>
Used to reference generic parameters.
<value>
Usage: <value>property-description</value>
is used to describe the value represented by the property. <summary> Tag for the new property. > Note that when you add a property through the Code wizard in the Visual Studio. 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. For example:
/// <summary> /// Gets or sets the title. /// </summary> /// <value> /// The title. /// </value> Public Virtual string Get set; }
<exception>
Usage: <exception cref="member">description</exception>
Used to describe an exception that can be thrown. For example:
/// <summary>///Gets the and validates property./// </summary>/// <param name= "PropertyName" >Name of the property.</param>/// <returns>Reflection Property Info Object</returns>/// <exception cref= "System.InvalidOperationException" >Model have no such property</exception>PrivateSystem.Reflection.PropertyInfo Getandvalidateproperty (stringPropertyName) { varproperty =Modeltype.getproperty (PropertyName); if(Property = =NULL) { property=Modeltype.getproperty (System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase (PropertyName)); if(Property = =NULL) { Throw NewInvalidOperationException (string. Format ("Property {0} doesn ' t exist in object {1}", PropertyName, Modeltype)); } } returnProperty ;}
Reference documents
- Https://msdn.microsoft.com/zh-cn/library/te6h7cxs%28v=vs.110%29.aspx
XML document comments in C #-recommended document Comment tags