title: .NET XmlSerializer : How to replace name of the xml tag?
body: <p>For some data export, what we are doing is just serializing the .Net objects like a list or Collection using XmlSerializer. We use something like this:</p>
  
  <pre><code>public static bool WriteToXMLFile(string fullFileNameWithPath, Object obj, Type ObjectType)
          {
              TextWriter xr = null;
              try
              {
                  XmlSerializer ser = new XmlSerializer(ObjectType);
                  xr = new StreamWriter(fullFileNameWithPath);
                  ser.Serialize(xr, obj);
              }
              catch (Exception ex)
              {
                  throw ex;
              }
              finally
              {
                  if(xr != null)
                      xr.Close();
              }
              return true;
          }
  </code></pre>
  
  <p>For a list of a type, the XML that is generated comes like the following segment:</p>
  
  <pre><code>&lt;ArrayOfMyObjects&gt;
      &lt;MyObject&gt;
      //content here
      &lt;/MyObject&gt;
  &lt;/ArrayOfMyObjects&gt;
  </code></pre>
  
  <p>But the expectation on the other side (receiver of this file is something like this:</p>
  
  <pre><code>&lt;MT_MyObjects&gt;
      &lt;MyObject&gt;
      //content here
      &lt;/MyObject&gt;
  &lt;/MT_MyObjects&gt;
  </code></pre>
  
  <p>So how can I change ArrayOfMyObjects to MT_MyObjects while serializing? I know it can be done using some Regx replacement also. But I wanted not to touch the output later.</p>
  
  <p><strong>Update: The solution:</strong></p>
  
  <p>I could solve the issue finally like this:</p>
  
  <pre><code>[Serializable]
  [XmlRoot("MT_LoadProfile")]
  public class LoadProfArray : List&lt;LoadProfile&gt;
  {
      //....
  }
  </code></pre>