温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

C#文档XML标记有哪些

发布时间:2021-12-01 11:44:14 来源:亿速云 阅读:126 作者:iii 栏目:编程语言

本篇内容介绍了“C#文档XML标记有哪些”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

C#文档XML标记的介绍

<c>:指示这行注释标识为Code

<code>:指示多行注释标识为Code

<example>:经常与<code>连用,用来给出如何使用某些成员的例子。

<exception>:指明一个成员会抛出哪些异常,经常与cref属性连用。

<include>:指明注释在哪些文件中,以及位置。

<list>:用来定义表头,经常与<item>连用

<newpara>:内部使用,如<remarks>或<returns>。让用户有机会给注释文本加入其他的结构。

<param>:说明参数的属性,编译器会检查参数的合法性。如果通不过,会在文档中产生!标识的警告。

<paramref>:类似<param>。

<permission>:标明用于成员的代码存取的安全性。

<remarks>:用于描述class或其它类型的描述性文字,不涉及具体细节(如果是这样,使用<summary>)。

<returns>:描述方法或函数的返回值。

<see>:指定一个链接。

<seealso>:指定要出现在See Also部分的文本。

<summary>:类型的描述性文字。它会被vs.net内置的IntelliSense使用并显示在对应的类型中。(即在vs.net中击键“.”出现的提示)

<value>:描述属性。

标记及描述

cref:可用于任何标记来提供一个代码元素的参考。编译器将检查这个代码元素是否存在,如不存在则在文档中用!标识。

name:用于<param>或<paramref>

C#文档XML标记使用的例子

1.<param>标记

/// <summary>   /// A method with a string array param.   /// </summary>   /// <param name="ss"></param>   public void Koo(string[] ss) {}

2.<returns>标记

/// <summary>   /// A nonvoid method.   /// </summary>   /// <returns>The result of the operation.</returns>   public int Noo() { return 0; }

3.<exception>标记和cref 属性:

/// <summary>   /// <exception cref="System.Exception">   /// Throws a FileIOException when...   /// </exception>   /// </summary>   public void Foo() {}

4.<c>, <code>, 和<example>标记

/// <summary>   /// <c>Hoo</c> is a method in the <c>Class1</c> class.   /// </summary>   public void Hoo() {}       /// <summary>   /// The Joo method.   /// <example>This example shows how to use Joo:   /// <code>   /// <newpara/>   /// public static void Main()   /// {   ///     Console.WriteLine(Class1.Joo());   /// }   /// <newpara/>   /// </code>   /// </example>   /// </summary>   public static int Joo() { return 0; }

5.<include> 标记语法:

<include file=''''filename'''' path=''''tagpath[@name="id"]'''' />       /// <include file=''''supporting.xml'''' path=''''MyDocs/MyMembers[@name="Class1"]/*'''' />   class Class1{   public static void Main() {}   }   supporting.xml   <MyDocs>       <MyMembers name="Class1">           <summary>           The summary for this type.           </summary>       </MyMembers>       <MyMembers name="Class2">           <summary>           Another type description.           </summary>       </MyMembers>   </MyDocs>

6.<list>标记语法及应用

<list type="bullet" │ "number" │ "table">       <listheader>           <term>term</term>           <description>description</description>       </listheader>       <item>           <term>term</term>           <description>description</description>       </item>   </list>       /// <remarks>Here is an example of a bulleted list:   /// <list type="bullet">   /// <item>   /// <description>Item 1.</description>   /// </item>   /// <item>   /// <description>Item 2.</description>   /// </item>   /// </list>   /// </remarks>   static void Main(string[] args) {}

“C#文档XML标记有哪些”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

xml
AI