16,722
社区成员




' Create the XmlSerializer.
Dim s As New XmlSerializer(GetType(TestProgram))
' To write the file, a TextWriter is required.
Dim writer As New StreamWriter(filename)
' Create an instance of the group to serialize, and set
' its properties.
Dim Test As New TestProgram()
Dim productInfo As New productInfo
productInfo.strProductName = "苹果充电器"
Test.ProductInfomation = productInfo
'#Zone " 1 "
Dim opentime As New TestTypeOpenTime
opentime.ID = 1
opentime.Name = "开机时间"
ReDim Test.OpenTime(0)
Test.OpenTime(0) = opentime
'#End Zone
'#Zone " 2 "
ReDim Preserve Test.CommonTest(0)
Dim comm1 As New TestTypeCommon
comm1.ID = 2
comm1.Name = "轻载"
Test.CommonTest(0) = comm1
'#End Zone
'#Zone " 3 "
Dim ocp As New TestTypeOcp
ocp.ID = 3
ocp.Name = "OCP测试"
ReDim Test.OCP(0)
Test.OCP(0) = ocp
'#End Zone
'#Zone " 4 "
ReDim Preserve Test.CommonTest(1)
Dim comm2 As New TestTypeCommon
comm2.ID = 4
comm2.Name = "重载"
Test.CommonTest(1) = comm2
'#End Zone
s.Serialize(writer, Test)
writer.Close()