从XmlCDataSection到XCData的隐式转换

时间:2016-02-09 09:54:43

标签: c# .net xml vb.net type-conversion

我有一个XmlNode函数,写XmlCDataSection然后返回XmlCDataSection

现在,我已将XNode转换为XmlNode,我想调用上述方法,但我需要将生成的XmlCDataSection转换为XCData。< / p>

这是用Vb.Net编写的伪代码:

<Extension>
Public Function CreateCDataSection(ByVal node As XNode) As XCData

    Dim xmlNode as XmlNode = 
        node.ConvertToXmlNode()

    Dim xmlCDataSection as XmlCDataSection = 
        XmlNodeExtensions.CreateCDataSection(xmlNode)

    ' Here is where I need help for the conversion:
    Dim xCData as XCData = xmlCDataSection.ConvertToXCData()

    Return xCData

End Function

如何将 XmlCDataSection 转换为 XCData

1 个答案:

答案 0 :(得分:1)

您可以使用XCData类型的构造函数来获取字符串参数

Return New XCData(someValue)

XCData Constructor (String)