title: Serialization of parent object
body: <p>I'm trying to serialize parent object like in this example</p>
  
  <pre><code>static void Main(string[] args)
      {
          Child child = new Child
              {
                  Id = 5,
                  Name = "John",
                  Address = "Address"
              };
  
          Parent parent = child;
  
          XmlSerializer serializer =new XmlSerializer(typeof(Parent));
          Stream stream=new MemoryStream();
  
          serializer.Serialize(stream,parent); //this line throws exception 
  
          Parent p2 = (Parent) serializer.Deserialize(stream);
  
          Console.ReadKey();
      }
  }
  
  [Serializable]
  public class Parent
  {
      public int Id { get; set; }
      public string Name { get; set; }
  }
  
  [Serializable]
  public class Child : Parent
  {
      public string Address { get; set; }
  }
  </code></pre>
  
  <p>The exception text that I'm getting is "The type CastParrentExample.Child was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically."
  What I'm trying to reach is to get true Parent class object without Child class fields.</p>