XComment 构造函数
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
初始化 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 参数为 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 参数为 null。
注解
此构造函数主要用于内部生成 XML 树的深层副本。