Imports System.Collections.Generic
Imports System.Collections
Imports System.Reflection
Imports System.Xml.Serialization
<XmlInclude(GetType(ProfileFormatNumber))>
Public Class ProfileFormat
<XmlElement(ElementName:="e1")>
Public Property Name As String = String.Empty
Public Class ProfileFormatNumber
<XmlElement(ElementName:="f1")>
Public Property Divider As Integer = 1
Public Class Serializer(Of T)
Public Shared Function Serialize(ByVal obj As T) As String
Dim xsSubmit As XmlSerializer = New XmlSerializer(GetType(T))
Using sww = New StringWriter()
Using writer As XmlTextWriter = New XmlTextWriter(sww) With {.Formatting = Formatting.Indented}
xsSubmit.Serialize(writer, obj)
Dim profileFormat = New ProfileFormatNumber With { .Name = "my name", .Divider = 111 }
Dim xml2 = Serializer(Of ProfileFormat).Serialize(profileFormat)