亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

c#如何使用 XML 文檔功能

 更新時間:2020年10月12日 15:08:27   作者:olprod  
這篇文章主要介紹了c#如何使用 XML 文檔功能,幫助大家更好的理解和使用c#,感興趣的朋友可以了解下

下面的示例提供對某個已存檔類型的基本概述。

示例

// If compiling from the command line, compile with: -doc:YourFileName.xml

/// <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 TestClass : TestInterface
{
  /// <summary>
  /// Store for the Name property.
  /// </summary>
  private string _name = null;

  /// <summary>
  /// The class constructor.
  /// </summary>
  public TestClass()
  {
    // 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 (_name == null)
      {
        throw new System.Exception("Name is null");
      }
      return _name;
    }
  }

  /// <summary>
  /// Description for SomeMethod.
  /// </summary>
  /// <param name="s"> Parameter description for s goes here.</param>
  /// <seealso cref="System.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 values 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;
  }

  public int InterfaceMethod(int n)
  {
    return n * n;
  }

  /// <summary>
  /// The entry point for the application.
  /// </summary>
  /// <param name="args"> A list of command line arguments.</param>
  static int Main(System.String[] args)
  {
    // TODO: Add code to start application here.
    return 0;
  }
}

/// <summary>
/// Documentation that describes the interface goes here.
/// </summary>
/// <remarks>
/// Details about the interface go here.
/// </remarks>
interface TestInterface
{
  /// <summary>
  /// Documentation that describes the method goes here.
  /// </summary>
  /// <param name="n">
  /// Parameter n requires an integer argument.
  /// </param>
  /// <returns>
  /// The method returns an integer.
  /// </returns>
  int InterfaceMethod(int n);
}

該示例生成一個包含以下內(nèi)容的 .xml 文件。

<?xml version="1.0"?>
<doc>
  <assembly>
    <name>xmlsample</name>
  </assembly>
  <members>
    <member name="T:TestClass">
      <summary>
      Class level summary documentation goes here.
      </summary>
      <remarks>
      Longer comments can be associated with a type or member through
      the remarks tag.
      </remarks>
    </member>
    <member name="F:TestClass._name">
      <summary>
      Store for the Name property.
      </summary>
    </member>
    <member name="M:TestClass.#ctor">
      <summary>
      The class constructor.
      </summary>
    </member>
    <member name="P:TestClass.Name">
      <summary>
      Name property.
      </summary>
      <value>
      A value tag is used to describe the property value.
      </value>
    </member>
    <member name="M:TestClass.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 member
      and the compiler will check that the reference exists.
      </seealso>
    </member>
    <member name="M:TestClass.SomeOtherMethod">
      <summary>
      Some other method.
      </summary>
      <returns>
      Return values are described through the returns tag.
      </returns>
      <seealso cref="M:TestClass.SomeMethod(System.String)">
      Notice the use of the cref attribute to reference a specific method.
      </seealso>
    </member>
    <member name="M:TestClass.Main(System.String[])">
      <summary>
      The entry point for the application.
      </summary>
      <param name="args"> A list of command line arguments.</param>
    </member>
    <member name="T:TestInterface">
      <summary>
      Documentation that describes the interface goes here.
      </summary>
      <remarks>
      Details about the interface go here.
      </remarks>
    </member>
    <member name="M:TestInterface.InterfaceMethod(System.Int32)">
      <summary>
      Documentation that describes the method goes here.
      </summary>
      <param name="n">
      Parameter n requires an integer argument.
      </param>
      <returns>
      The method returns an integer.
      </returns>
    </member>
  </members>
</doc>

編譯代碼

若要編譯該示例,請輸入以下命令:

csc XMLsample.cs /doc:XMLsample.xml

此命令創(chuàng)建 XML 文件 XMLsample.xml,可在瀏覽器中或使用 TYPE 命令查看該文件。

可靠編程

XML 文檔以 /// 開頭。 創(chuàng)建新項目時,向?qū)胖靡恍┮?/// 開頭的行。 處理這些注釋時存在一些限制:

1.文檔必須是格式正確的 XML。 如果 XML 格式不正確,則會生成警告,并且文檔文件將包含一條注釋,指出遇到錯誤。

2.開發(fā)人員可以隨意創(chuàng)建自己的標記集。 有一組推薦的標記。 部分建議標記具有特殊含義:

  • <param> 標記用于描述參數(shù)。 如果已使用,編譯器會驗證該參數(shù)是否存在,以及文檔是否描述了所有參數(shù)。 如果驗證失敗,編譯器會發(fā)出警告。
  • cref 屬性可以附加到任何標記,以引用代碼元素。 編譯器驗證此代碼元素是否存在。 如果驗證失敗,編譯器會發(fā)出警告。 編譯器在查找 cref 屬性中描述的類型時會考慮所有 using 語句。
  • <summary> 標記由 Visual Studio 中的 IntelliSense 用于顯示有關某個類型或成員的附加信息。

備注

XML 文件不提供有關該類型和成員的完整信息(例如,它不包含任何類型信息)。 若要獲取有關類型或成員的完整信息,請將文檔文件與對實際類型或成員的反射一起使用。

以上就是c#如何使用 XML 文檔功能的詳細內(nèi)容,更多關于c# 使用 XML 文檔功能的資料請關注腳本之家其它相關文章!

相關文章

  • C#在MEF框架中手動導入依賴模塊

    C#在MEF框架中手動導入依賴模塊

    這篇文章介紹了C#在MEF框架中手動導入依賴模塊的方法,文中通過示例代碼介紹的非常詳細。對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-06-06
  • C#編程中使用ref和out關鍵字來傳遞數(shù)組對象的用法

    C#編程中使用ref和out關鍵字來傳遞數(shù)組對象的用法

    這篇文章主要介紹了C#編程中使用ref和out關鍵字來傳遞數(shù)組對象的用法,在C#中數(shù)組也是對象可以被傳遞,需要的朋友可以參考下
    2016-01-01
  • Unity3D舊電視濾鏡shader的實現(xiàn)示例

    Unity3D舊電視濾鏡shader的實現(xiàn)示例

    這篇文章主要介紹了Unity3D舊電視濾鏡shader的實現(xiàn)示例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2021-04-04
  • C#實現(xiàn)簡單成績管理系統(tǒng)的完整步驟

    C#實現(xiàn)簡單成績管理系統(tǒng)的完整步驟

    這篇文章主要給大家介紹了關于C#實現(xiàn)簡單成績管理系統(tǒng)的完整步驟,文中通過示例代碼介紹的非常詳細,對大家的學習或者使用C#具有一定的參考學習價值,需要的朋友們下面來一起學習學習吧
    2019-11-11
  • 探討c#中的unchecked是什么意思,起什么作用?

    探討c#中的unchecked是什么意思,起什么作用?

    本篇文章是對c#中的unchecked進行了詳細的分析介紹,需要的朋友參考下
    2013-06-06
  • C#實現(xiàn)異步編程的方法

    C#實現(xiàn)異步編程的方法

    這篇文章主要為大家詳細介紹了C#實現(xiàn)異步編程的方法,什么是異步,如何實現(xiàn)異步編程,感興趣的小伙伴們可以參考一下
    2017-07-07
  • C# 數(shù)獨求解算法的實現(xiàn)

    C# 數(shù)獨求解算法的實現(xiàn)

    這篇文章主要介紹了C# 數(shù)獨求解算法的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧
    2020-01-01
  • 深入c#繪制驗證碼的詳解

    深入c#繪制驗證碼的詳解

    本篇文章是對用c#繪制驗證碼的方法進行了詳細的分析介紹,需要的朋友參考下
    2013-06-06
  • C#中的Linq?to?JSON操作詳解

    C#中的Linq?to?JSON操作詳解

    本文詳細講解了C#中的Linq?to?JSON操作,文中通過示例代碼介紹的非常詳細。對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2022-06-06
  • 基于WPF實現(xiàn)擬物音量控件

    基于WPF實現(xiàn)擬物音量控件

    這篇文章主要為大家詳細介紹了如何基于WPF實現(xiàn)簡單的擬物音量控件,文中的示例代碼講解詳細,對我們學習或工作有一定幫助,感興趣的小伙伴可以了解一下
    2023-05-05

最新評論