XComment 建構函式

定義

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

多載

XComment(String)

使用指定的字串內容,初始化 XComment 類別的新執行個體。

XComment(XComment)

從現有的註解節點,初始化 XComment 類別的新執行個體。

XComment(String)

使用指定的字串內容,初始化 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 類別的新執行個體。

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 樹狀結構的深層複本。

另請參閱

適用於