I vave 2 class:
public class ClassA
public class ClassB (from another namespace) : ClassA
I use methdo at ClassA
public static ClassA Deserialize(string path)
{
ClassA classA;
//classA=code...
return classA;
}
I invoke this method at classB
public void DoSomething()
{
ClassB classB=(ClassB)ClassA.Deserialize("c:\directory\file.xml);
}
method deserialize works, but i get error that cannont cast ClassA to ClassB.
How to deal with this?
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;
}
Maybe something with deserialize(string path, Type objectType ) ??
I could can change method Deserialize if it would necessary