# C1.Win.List.Util.Xml.Serialization.Serializer.Serialize

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_Win_List_Util_Xml_Serialization_Serializer_Serialize_" data-uid="C1.Win.List.Util.Xml.Serialization.Serializer.Serialize*">Serialize Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_Win_List_Util_Xml_Serialization_Serializer_Serialize_" data-uid="C1.Win.List.Util.Xml.Serialization.Serializer.Serialize*"></a>
<h4 id="C1_Win_List_Util_Xml_Serialization_Serializer_Serialize_System_IO_Stream_System_Object_System_Xml_Serialization_XmlSerializerNamespaces_System_Xml_XmlTextWriter__" data-uid="C1.Win.List.Util.Xml.Serialization.Serializer.Serialize(System.IO.Stream,System.Object,System.Xml.Serialization.XmlSerializerNamespaces,System.Xml.XmlTextWriter@)">Serialize(Stream, object, XmlSerializerNamespaces, out XmlTextWriter)</h4>
<div class="markdown level1 summary"><p>Serializes the specified Object and writes the XML-document instance to a file using the specified Stream.
DOES NOT close the underlying stream. Useful for copying objects.
Caller is responsible to call out writer.Close() to close writer and underlying stream.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void Serialize(Stream stream, object o, XmlSerializerNamespaces namespaces, out XmlTextWriter writer)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub Serialize(stream As Stream, o As Object, namespaces As XmlSerializerNamespaces, ByRef writer As XmlTextWriter)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.io.stream">Stream</a></td>
      <td><span class="parametername">stream</span></td>
      <td><p>The Stream used to write the XML-document instance</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></td>
      <td><span class="parametername">o</span></td>
      <td><p>The Object to serialize</p>
</td>
    </tr>
    <tr>
      <td><span class="xref">XmlSerializerNamespaces</span></td>
      <td><span class="parametername">namespaces</span></td>
      <td><p>The XmlSerializerNamespaces referenced by the object</p>
</td>
    </tr>
    <tr>
      <td><span class="xref">XmlTextWriter</span></td>
      <td><span class="parametername">writer</span></td>
      <td><p>The XmlWriter object reference. Call writer.Close after working with stream/writer.</p>
</td>
    </tr>
  </tbody>
</table>


<a id="C1_Win_List_Util_Xml_Serialization_Serializer_Serialize_" data-uid="C1.Win.List.Util.Xml.Serialization.Serializer.Serialize*"></a>
<h4 id="C1_Win_List_Util_Xml_Serialization_Serializer_Serialize_System_IO_Stream_System_Object_System_Xml_Serialization_XmlSerializerNamespaces_" data-uid="C1.Win.List.Util.Xml.Serialization.Serializer.Serialize(System.IO.Stream,System.Object,System.Xml.Serialization.XmlSerializerNamespaces)">Serialize(Stream, object, XmlSerializerNamespaces)</h4>
<div class="markdown level1 summary"><p>Serializes the specified Object and writes the XML-document instance to a file using the specified Stream.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void Serialize(Stream stream, object o, XmlSerializerNamespaces namespaces)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub Serialize(stream As Stream, o As Object, namespaces As XmlSerializerNamespaces)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.io.stream">Stream</a></td>
      <td><span class="parametername">stream</span></td>
      <td><p>The Stream used to write the XML-document instance</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></td>
      <td><span class="parametername">o</span></td>
      <td><p>The Object to serialize</p>
</td>
    </tr>
    <tr>
      <td><span class="xref">XmlSerializerNamespaces</span></td>
      <td><span class="parametername">namespaces</span></td>
      <td><p>The XmlSerializerNamespaces referenced by the object</p>
</td>
    </tr>
  </tbody>
</table>


<a id="C1_Win_List_Util_Xml_Serialization_Serializer_Serialize_" data-uid="C1.Win.List.Util.Xml.Serialization.Serializer.Serialize*"></a>
<h4 id="C1_Win_List_Util_Xml_Serialization_Serializer_Serialize_System_Xml_XmlTextWriter_System_Object_System_Xml_Serialization_XmlSerializerNamespaces_" data-uid="C1.Win.List.Util.Xml.Serialization.Serializer.Serialize(System.Xml.XmlTextWriter,System.Object,System.Xml.Serialization.XmlSerializerNamespaces)">Serialize(XmlTextWriter, object, XmlSerializerNamespaces)</h4>
<div class="markdown level1 summary"><p>Serializes the specified Object and writes the XML-document instance to a file using the specified XmlWriter</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void Serialize(XmlTextWriter writer, object o, XmlSerializerNamespaces namespaces)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub Serialize(writer As XmlTextWriter, o As Object, namespaces As XmlSerializerNamespaces)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><span class="xref">XmlTextWriter</span></td>
      <td><span class="parametername">writer</span></td>
      <td><p>The XmlWriter used to write the XML-document instance</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></td>
      <td><span class="parametername">o</span></td>
      <td><p>The Object to serialize</p>
</td>
    </tr>
    <tr>
      <td><span class="xref">XmlSerializerNamespaces</span></td>
      <td><span class="parametername">namespaces</span></td>
      <td><p>The XmlSerializerNamespaces referenced by the object</p>
</td>
    </tr>
  </tbody>
</table>


<a id="C1_Win_List_Util_Xml_Serialization_Serializer_Serialize_" data-uid="C1.Win.List.Util.Xml.Serialization.Serializer.Serialize*"></a>
<h4 id="C1_Win_List_Util_Xml_Serialization_Serializer_Serialize_System_IO_Stream_System_Object_System_Reflection_MemberInfo_System_Xml_Serialization_XmlSerializerNamespaces_System_Xml_XmlTextWriter__" data-uid="C1.Win.List.Util.Xml.Serialization.Serializer.Serialize(System.IO.Stream,System.Object,System.Reflection.MemberInfo,System.Xml.Serialization.XmlSerializerNamespaces,System.Xml.XmlTextWriter@)">Serialize(Stream, object, MemberInfo, XmlSerializerNamespaces, out XmlTextWriter)</h4>
<div class="markdown level1 summary"><p>Serializes the specified Object and writes the XML-document instance to a file using the specified Stream.
DOES NOT close the underlying stream. Useful for copying objects.
Caller is responsible to call out writer.Close() to close writer and underlying stream.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void Serialize(Stream stream, object o, MemberInfo mi, XmlSerializerNamespaces namespaces, out XmlTextWriter writer)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub Serialize(stream As Stream, o As Object, mi As MemberInfo, namespaces As XmlSerializerNamespaces, ByRef writer As XmlTextWriter)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.io.stream">Stream</a></td>
      <td><span class="parametername">stream</span></td>
      <td><p>The Stream used to write the XML-document instance</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></td>
      <td><span class="parametername">o</span></td>
      <td><p>The Object to serialize</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.reflection.memberinfo">MemberInfo</a></td>
      <td><span class="parametername">mi</span></td>
      <td><p>The FieldInfo or MemberInfo object context for the object to serialize</p>
</td>
    </tr>
    <tr>
      <td><span class="xref">XmlSerializerNamespaces</span></td>
      <td><span class="parametername">namespaces</span></td>
      <td><p>The XmlSerializerNamespaces referenced by the object</p>
</td>
    </tr>
    <tr>
      <td><span class="xref">XmlTextWriter</span></td>
      <td><span class="parametername">writer</span></td>
      <td><p>The XmlWriter object reference. Call writer.Close after working with stream/writer.</p>
</td>
    </tr>
  </tbody>
</table>


<a id="C1_Win_List_Util_Xml_Serialization_Serializer_Serialize_" data-uid="C1.Win.List.Util.Xml.Serialization.Serializer.Serialize*"></a>
<h4 id="C1_Win_List_Util_Xml_Serialization_Serializer_Serialize_System_IO_Stream_System_Object_System_Reflection_MemberInfo_System_Xml_Serialization_XmlSerializerNamespaces_System_Xml_XmlTextWriter__System_Attribute___" data-uid="C1.Win.List.Util.Xml.Serialization.Serializer.Serialize(System.IO.Stream,System.Object,System.Reflection.MemberInfo,System.Xml.Serialization.XmlSerializerNamespaces,System.Xml.XmlTextWriter@,System.Attribute[])">Serialize(Stream, object, MemberInfo, XmlSerializerNamespaces, out XmlTextWriter, Attribute[])</h4>
<div class="markdown level1 summary"></div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void Serialize(Stream stream, object o, MemberInfo mi, XmlSerializerNamespaces namespaces, out XmlTextWriter writer, Attribute[] filter)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub Serialize(stream As Stream, o As Object, mi As MemberInfo, namespaces As XmlSerializerNamespaces, ByRef writer As XmlTextWriter, filter As Attribute())</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.io.stream">Stream</a></td>
      <td><span class="parametername">stream</span></td>
      <td></td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></td>
      <td><span class="parametername">o</span></td>
      <td></td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.reflection.memberinfo">MemberInfo</a></td>
      <td><span class="parametername">mi</span></td>
      <td></td>
    </tr>
    <tr>
      <td><span class="xref">XmlSerializerNamespaces</span></td>
      <td><span class="parametername">namespaces</span></td>
      <td></td>
    </tr>
    <tr>
      <td><span class="xref">XmlTextWriter</span></td>
      <td><span class="parametername">writer</span></td>
      <td></td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.attribute">Attribute</a>[]</td>
      <td><span class="parametername">filter</span></td>
      <td></td>
    </tr>
  </tbody>
</table>


<a id="C1_Win_List_Util_Xml_Serialization_Serializer_Serialize_" data-uid="C1.Win.List.Util.Xml.Serialization.Serializer.Serialize*"></a>
<h4 id="C1_Win_List_Util_Xml_Serialization_Serializer_Serialize_System_IO_Stream_System_Object_System_Reflection_MemberInfo_System_Xml_Serialization_XmlSerializerNamespaces_" data-uid="C1.Win.List.Util.Xml.Serialization.Serializer.Serialize(System.IO.Stream,System.Object,System.Reflection.MemberInfo,System.Xml.Serialization.XmlSerializerNamespaces)">Serialize(Stream, object, MemberInfo, XmlSerializerNamespaces)</h4>
<div class="markdown level1 summary"><p>Serializes the specified Object and writes the XML-document instance to a file using the specified Stream.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void Serialize(Stream stream, object o, MemberInfo mi, XmlSerializerNamespaces namespaces)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub Serialize(stream As Stream, o As Object, mi As MemberInfo, namespaces As XmlSerializerNamespaces)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.io.stream">Stream</a></td>
      <td><span class="parametername">stream</span></td>
      <td><p>The Stream used to write the XML-document instance</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></td>
      <td><span class="parametername">o</span></td>
      <td><p>The Object to serialize</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.reflection.memberinfo">MemberInfo</a></td>
      <td><span class="parametername">mi</span></td>
      <td><p>The FieldInfo or MemberInfo object context for the object to serialize</p>
</td>
    </tr>
    <tr>
      <td><span class="xref">XmlSerializerNamespaces</span></td>
      <td><span class="parametername">namespaces</span></td>
      <td><p>The XmlSerializerNamespaces referenced by the object</p>
</td>
    </tr>
  </tbody>
</table>


<a id="C1_Win_List_Util_Xml_Serialization_Serializer_Serialize_" data-uid="C1.Win.List.Util.Xml.Serialization.Serializer.Serialize*"></a>
<h4 id="C1_Win_List_Util_Xml_Serialization_Serializer_Serialize_System_Xml_XmlTextWriter_System_Object_System_Reflection_MemberInfo_System_Xml_Serialization_XmlSerializerNamespaces_System_Attribute___" data-uid="C1.Win.List.Util.Xml.Serialization.Serializer.Serialize(System.Xml.XmlTextWriter,System.Object,System.Reflection.MemberInfo,System.Xml.Serialization.XmlSerializerNamespaces,System.Attribute[])">Serialize(XmlTextWriter, object, MemberInfo, XmlSerializerNamespaces, Attribute[])</h4>
<div class="markdown level1 summary"><p>Serializes the specified Object and writes the XML-document instance to a file using the specified XmlWriter</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void Serialize(XmlTextWriter writer, object o, MemberInfo mi, XmlSerializerNamespaces namespaces, Attribute[] filter)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub Serialize(writer As XmlTextWriter, o As Object, mi As MemberInfo, namespaces As XmlSerializerNamespaces, filter As Attribute())</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><span class="xref">XmlTextWriter</span></td>
      <td><span class="parametername">writer</span></td>
      <td><p>The XmlWriter used to write the XML-document instance</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></td>
      <td><span class="parametername">o</span></td>
      <td><p>The Object to serialize</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.reflection.memberinfo">MemberInfo</a></td>
      <td><span class="parametername">mi</span></td>
      <td><p>The FieldInfo or MemberInfo object context for the object to serialize</p>
</td>
    </tr>
    <tr>
      <td><span class="xref">XmlSerializerNamespaces</span></td>
      <td><span class="parametername">namespaces</span></td>
      <td><p>The XmlSerializerNamespaces referenced by the object</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.attribute">Attribute</a>[]</td>
      <td><span class="parametername">filter</span></td>
      <td><p>Array of attributes that specify what to serialize</p>
</td>
    </tr>
  </tbody>
</table>


<a id="C1_Win_List_Util_Xml_Serialization_Serializer_Serialize_" data-uid="C1.Win.List.Util.Xml.Serialization.Serializer.Serialize*"></a>
<h4 id="C1_Win_List_Util_Xml_Serialization_Serializer_Serialize_System_Xml_XmlTextWriter_System_Object_System_Reflection_MemberInfo_System_Xml_Serialization_XmlSerializerNamespaces_" data-uid="C1.Win.List.Util.Xml.Serialization.Serializer.Serialize(System.Xml.XmlTextWriter,System.Object,System.Reflection.MemberInfo,System.Xml.Serialization.XmlSerializerNamespaces)">Serialize(XmlTextWriter, object, MemberInfo, XmlSerializerNamespaces)</h4>
<div class="markdown level1 summary"><p>Serializes the specified Object and writes the XML-document instance to a file using the specified XmlWriter</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void Serialize(XmlTextWriter writer, object o, MemberInfo mi, XmlSerializerNamespaces namespaces)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub Serialize(writer As XmlTextWriter, o As Object, mi As MemberInfo, namespaces As XmlSerializerNamespaces)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><span class="xref">XmlTextWriter</span></td>
      <td><span class="parametername">writer</span></td>
      <td><p>The XmlWriter used to write the XML-document instance</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></td>
      <td><span class="parametername">o</span></td>
      <td><p>The Object to serialize</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.reflection.memberinfo">MemberInfo</a></td>
      <td><span class="parametername">mi</span></td>
      <td><p>The FieldInfo or MemberInfo object context for the object to serialize</p>
</td>
    </tr>
    <tr>
      <td><span class="xref">XmlSerializerNamespaces</span></td>
      <td><span class="parametername">namespaces</span></td>
      <td><p>The XmlSerializerNamespaces referenced by the object</p>
</td>
    </tr>
  </tbody>
</table>


<a id="C1_Win_List_Util_Xml_Serialization_Serializer_Serialize_" data-uid="C1.Win.List.Util.Xml.Serialization.Serializer.Serialize*"></a>
<h4 id="C1_Win_List_Util_Xml_Serialization_Serializer_Serialize_System_Object_System_Reflection_MemberInfo_System_Xml_Serialization_XmlSerializerNamespaces_" data-uid="C1.Win.List.Util.Xml.Serialization.Serializer.Serialize(System.Object,System.Reflection.MemberInfo,System.Xml.Serialization.XmlSerializerNamespaces)">Serialize(object, MemberInfo, XmlSerializerNamespaces)</h4>
<div class="markdown level1 summary"><p>Serializes the specified object to an XML formatted string.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public string Serialize(object o, MemberInfo mi, XmlSerializerNamespaces namespaces)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function Serialize(o As Object, mi As MemberInfo, namespaces As XmlSerializerNamespaces) As String</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></td>
      <td><span class="parametername">o</span></td>
      <td></td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.reflection.memberinfo">MemberInfo</a></td>
      <td><span class="parametername">mi</span></td>
      <td></td>
    </tr>
    <tr>
      <td><span class="xref">XmlSerializerNamespaces</span></td>
      <td><span class="parametername">namespaces</span></td>
      <td></td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td></td>
    </tr>
  </tbody>
</table>
</div>
