本文整理汇总了VB.NET中System.Xml.Serialization.XmlArrayItemAttribute.IsNullable属性的典型用法代码示例。如果您正苦于以下问题:VB.NET XmlArrayItemAttribute.IsNullable属性的具体用法?VB.NET XmlArrayItemAttribute.IsNullable怎么用?VB.NET XmlArrayItemAttribute.IsNullable使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Xml.Serialization.XmlArrayItemAttribute
的用法示例。
在下文中一共展示了XmlArrayItemAttribute.IsNullable属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Group
Option Explicit
Option Strict
Imports System.IO
Imports System.Xml.Serialization
Public Class Group
<XmlArray(IsNullable := True), _
XmlArrayItem(GetType(Manager), IsNullable := False), _
XmlArrayItem(GetType(Employee), IsNullable := False)> _
Public Employees() As Employee
End Class
Public Class Employee
Public Name As String
End Class
Public Class Manager
Inherits Employee
Public Level As Integer
End Class
Public Class Run
Public Shared Sub Main()
Dim test As New Run()
test.SerializeObject("TypeDoc.xml")
End Sub
Public Sub SerializeObject(filename As String)
Dim s As New XmlSerializer(GetType(Group))
' To write the file, a TextWriter is required.
Dim writer As New StreamWriter(filename)
' Creates the object to serialize.
Dim group As New Group()
' Creates a null Manager object.
Dim mgr As Manager = Nothing
' Creates a null Employee object.
Dim y As Employee = Nothing
group.Employees = New Employee() {mgr, y}
' Serializes the object and closes the TextWriter.
s.Serialize(writer, group)
writer.Close()
End Sub
End Class