title: Placing a Property into a Different XML Namespace with XML Serialization
body: <p>I am using VSTS2008 + C# + .Net 3.0. I am using below code to serialize XML, here is my current code and serialized XML file. My purpose is I want to make MyInnerObjectProperties belongs to a special XML namespace (<a href="http://foo/2009" rel="nofollow noreferrer">http://foo/2009</a>) and making this namespace as default namespace. Any ideas how to implement this?</p>
  
  <p>Current output:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;MyClass xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
    &lt;MyObjectProperty&gt;
      &lt;MyInnerObjectProperties&gt;
        &lt;MyInnerObjectProperty&gt;
          &lt;ObjectName&gt;Foo Type&lt;/ObjectName&gt;
        &lt;/MyInnerObjectProperty&gt;
        &lt;MyInnerObjectProperty&gt;
          &lt;ObjectName&gt;Goo Type&lt;/ObjectName&gt;
        &lt;/MyInnerObjectProperty&gt;
      &lt;/MyInnerObjectProperties&gt;
    &lt;/MyObjectProperty&gt;
  &lt;/MyClass&gt;
  </code></pre>
  
  <p>Current code:</p>
  
  <pre><code>public class MyClass
  {
      private MyObject[] _myObjectProperty;
  
      [XmlElement(IsNullable=false)]
      public MyObject[] MyObjectProperty
      {
          get
          {
              return _myObjectProperty;
          }
          set
          {
              _myObjectProperty = value;
          }
      }
  }
  public class MyObject
  {
      private MyInnerObject[] _myInnerObjectProperty;
  
      [XmlArrayItemAttribute("MyInnerObjectProperty", typeof(MyInnerObject),  IsNullable=false)]
      public MyInnerObject[] MyInnerObjectProperties
      {
          get
          {
              return _myInnerObjectProperty;
          }
          set
          {
              _myInnerObjectProperty = value;
          }
      }
  }
  
  public class MyInnerObject
  {
      public string ObjectName;
  }
  
  public class Program
  {
      static void Main(string[] args)
      {
          XmlSerializer s = new XmlSerializer(typeof(MyClass));
          FileStream fs = new FileStream("foo.xml", FileMode.Create);
          MyClass instance = new MyClass();
          instance.MyObjectProperty = new MyObject[1];
          instance.MyObjectProperty[0] = new MyObject();
          instance.MyObjectProperty[0].MyInnerObjectProperties = new MyInnerObject[2];
          instance.MyObjectProperty[0].MyInnerObjectProperties[0] = new MyInnerObject();
          instance.MyObjectProperty[0].MyInnerObjectProperties[0].ObjectName = "Foo Type";
          instance.MyObjectProperty[0].MyInnerObjectProperties[1] = new MyInnerObject();
          instance.MyObjectProperty[0].MyInnerObjectProperties[1].ObjectName = "Goo Type";
  
          s.Serialize(fs, instance);
  
          return;
      }
  }
  </code></pre>