国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
c#XML文檔教程

一個基本的C#xml文檔教程

 

C# 提供一種機制,供開發(fā)人員使用 xml 將其代碼存檔。在源代碼文件中,以下代碼行可以作為注釋處理并放在文件中:以 /// 開始的行;在用戶定義的類型(如類、委托或接口)、某成員(如字段、事件、屬性或方法)或某命名空間聲明之前的行。

 

示例
 

下面的示例提供對某個已存檔的類型的基本概述。若要編譯該示例,請鍵入以下命令行:

csc xmlsample.cs /doc:xmlsample.xml

這將創(chuàng)建 xml 文件 xmlsample.xml,您可以在瀏覽器中或使用 TYPE 命令查看該文件。

// xmlsample.cs// compile with: /doc:xmlsample.xmlusing System;/// <summary>/// Class level summary documentation goes here.</summary>/// <remarks>/// Longer comments can be associated with a type or member/// through the remarks tag</remarks>public class SomeClass{/// <summary>/// Store for the name property</summary>private string myName = null;/// <summary>/// The class constructor. </summary>public SomeClass(){// TODO: Add Constructor Logic here}/// <summary>/// Name property </summary>/// <value>/// A value tag is used to describe the property value</value>public string Name{get{if ( myName == null ){throw new Exception("Name is null");}return myName;}}/// <summary>/// Description for SomeMethod.</summary>/// <param name="s"> Parameter description for s goes here</param>/// <seealso cref="String">/// You can use the cref attribute on any tag to reference a type or member/// and the compiler will check that the reference exists. </seealso>public void SomeMethod(string s){}/// <summary>/// Some other method. </summary>/// <returns>/// Return results are described through the returns tag.</returns>/// <seealso cref="SomeMethod(string)">/// Notice the use of the cref attribute to reference a specific method </seealso>public int SomeOtherMethod(){return 0;}/// <summary>/// The entry point for the application./// </summary>/// <param name="args"> A list of command line arguments</param>public static int Main(String[] args){// TODO: Add code to start application herereturn 0;}}

 

代碼討論
[編輯]

xml 文檔以 /// 開頭。創(chuàng)建新項目時,向?qū)槟湃胍恍┢鹗?/// 行。對這些注釋的處理有一些限制:

  • 文檔必須是符合標準格式的 xml。如果 xml 不符合標準格式,將生成警告,并且文檔文件將包含一條注釋,指出遇到錯誤。有關(guān)符合標準格式的 xml 的更多信息,請參見 xml 詞匯表。
  • 開發(fā)人員可自由創(chuàng)建自己的標記集。有一套建議的標記(請參見“其他閱讀材料”部分)。某些建議的標記具有特殊含義:
    • <param> 標記用于描述參數(shù)。如果使用,編譯器將驗證參數(shù)是否存在,以及文檔中是否描述了所有參數(shù)。如果驗證失敗,則編譯器發(fā)出警告。
    • cref 屬性可以附加到任意標記,以提供對代碼元素的引用。編譯器將驗證該代碼元素是否存在。如果驗證失敗,則編譯器發(fā)出警告。查找 cref 屬性中描述的類型時,編譯器還考慮任何 using 語句。
    • <summary> 標記由 Visual Studio 內(nèi)的“智能感知”使用,用來顯示類型或成員的其他相關(guān)信息。

 

示例輸出
[編輯]

以下是從上面的類生成的 xml 文件:

<?xml version="1.0"?><doc><assembly><name>xmlsample</name></assembly><members><member name="T:SomeClass"><summary>Class level summary documentation goes here.</summary><remarks>Longer comments can be associated with a type or memberthrough the remarks tag</remarks></member><member name="F:SomeClass.myName"><summary>Store for the name property</summary></member><member name="M:SomeClass.#ctor"><summary>The class constructor.</summary></member><member name="M:SomeClass.SomeMethod(System.String)"><summary>Description for SomeMethod.</summary><param name="s"> Parameter description for s goes here</param><seealso cref="T:System.String">You can use the cref attribute on any tag to reference a type or memberand the compiler will check that the reference exists. </seealso></member><member name="M:SomeClass.SomeOtherMethod"><summary>Some other method. </summary><returns>Return results are described through the returns tag.</returns><seealso cref="M:SomeClass.SomeMethod(System.String)">Notice the use of the cref attribute to reference a specific method </seealso></member><member name="M:SomeClass.Main(System.String[])"><summary>The entry point for the application.</summary><param name="args"> A list of command line arguments</param></member><member name="P:SomeClass.Name"><summary>Name property </summary><value>A value tag is used to describe the property value</value></member></members></doc>
注意   xml 文件并不提供有關(guān)類型和成員的完整信息(例如,它不包含任何類型信息)。若要獲得有關(guān)類型或成員的完整信息,文檔文件必須與實際類型或成員上的反射一起使用。
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
編寫并生成XML文檔注釋 - 光輝歲月 - 博客園
C#文檔自動化
Quartz.net官方開發(fā)指南 第七課 : TriggerListeners和JobListeners - 自由、創(chuàng)新、研究、探索 - 博客園
OFFICE 的加載項(add in)(轉(zhuǎn))
用C#寫Office插件 (ZT)
幾種數(shù)據(jù)庫的大數(shù)據(jù)批量插入
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服