本文整理匯總了VB.NET中System.Xml.Serialization.XmlRootAttribute.IsNullable屬性的典型用法代碼示例。如果您正苦於以下問題:VB.NET XmlRootAttribute.IsNullable屬性的具體用法?VB.NET XmlRootAttribute.IsNullable怎麽用?VB.NET XmlRootAttribute.IsNullable使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類System.Xml.Serialization.XmlRootAttribute
的用法示例。
在下文中一共展示了XmlRootAttribute.IsNullable屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Main
' 導入命名空間
Imports System.IO
Imports System.Xml.Serialization
Imports System.Xml
' Apply the XmlRootAttribute and set the IsNullable property to false.
<XmlRoot(IsNullable := False)> _
Public Class Group
Public Name As String
End Class
Public Class Run
Public Shared Sub Main()
Console.WriteLine("Running")
Dim test As New Run()
test.SerializeObject("NullDoc.xml")
End Sub
Public Sub SerializeObject(ByVal filename As String)
Dim s As New XmlSerializer(GetType(Group))
' Writing the file requires a TextWriter.
Dim writer As New StreamWriter(filename)
' Create the object to serialize.
Dim mygroup As Group = Nothing
' Serialize the object, and close the TextWriter.
s.Serialize(writer, mygroup)
writer.Close()
End Sub
End Class