title: Casting classes
body: <p>I have 2 classes:</p>
  
  <p>public class ClassA</p>
  
  <p>public class ClassB (from another namespace) : ClassA</p>
  
  <p>I use method at ClassA</p>
  
  <pre><code>public static ClassA Deserialize(string path)
  {
  ClassA classA;
  
  //classA=code...
  
  return classA;
  }
  </code></pre>
  
  <p>I invoke this method at classB</p>
  
  <pre><code>public void DoSomething()
  {
  ClassB classB=(ClassB)ClassA.Deserialize("c:\directory\file.xml);
  }
  </code></pre>
  
  <p>method deserialize works, but i get error that cannont cast ClassA to ClassB.</p>
  
  <p>How to deal with this?</p>
  
  <pre><code> public static ClassA DeserializeFromXml(string path)
          {
  
   XmlSerializer s = new XmlSerializer(typeof(ClassA));
              ClaasA h;
  
              TextReader r = new StreamReader(path);
  
  
                  h = (ClassA)s.Deserialize(r);
  
                  r.Close();
  
                  return h;
  }
  </code></pre>
  
  <p>Maybe something with deserialize(string path, Type objectType ) ?? </p>
  
  <p>I could can change method Deserialize if it would necessary</p>