語言

XComment 建構函式

定義

初始化 XComment 類別的新執行個體。

多載

名稱 Description
XComment(String)

初始化一個包含指定字串內容的 XComment 類別新實例。

XComment(XComment)

從現有的註解節點初始化該 XComment 類別的新實例。

XComment(String)

來源:
XComment.cs
來源:
XComment.cs
來源:
XComment.cs
來源:
XComment.cs
來源:
XComment.cs

初始化一個包含指定字串內容的 XComment 類別新實例。

public:
 XComment(System::String ^ value);
public XComment(string value);
new System.Xml.Linq.XComment : string -> System.Xml.Linq.XComment
Public Sub New (value As String)

參數

value
String

一個包含新 XComment 物件內容的字串。

例外狀況

參數 value 為 null。

範例

以下範例建立一個包含註解的元素作為子節點。

XElement root = new XElement("Root",
    new XComment("This is a comment")
);
Console.WriteLine(root);
Dim root As XElement = <Root>
                           <!--This is a comment-->
                       </Root>
Console.WriteLine(root)

此範例會產生下列輸出:

<Root>
  <!--This is a comment-->
</Root>

另請參閱

適用於

XComment(XComment)

來源:
XComment.cs
來源:
XComment.cs
來源:
XComment.cs
來源:
XComment.cs
來源:
XComment.cs

從現有的註解節點初始化該 XComment 類別的新實例。

public:
 XComment(System::Xml::Linq::XComment ^ other);
public XComment(System.Xml.Linq.XComment other);
new System.Xml.Linq.XComment : System.Xml.Linq.XComment -> System.Xml.Linq.XComment
Public Sub New (other As XComment)

參數

other
XComment

XComment要複製的節點。

例外狀況

參數 other 為 null。

備註

此建構器主要用於內部製作 XML 樹的深度複製。

另請參閱

適用於