I have two classes that both inherit from the same base class. I will be deserializing objects from XML text files. How do I tell what class the objected represented in the text file is so I can deserialize into the right instance of class?
I developed the code below using the base class. I now actually have two classes that inherit the Robot class.
Code:If File.Exists(fullPath) Then Dim rbt As New Robot Dim reader As New System.Xml.Serialization.XmlSerializer(GetType(Robot)) Dim file As New System.IO.StreamReader(fullPath) rbt = CType(reader.Deserialize(file), Robot) file.Close() Return rbt Else Return Nothing End If