C
Charles Law
I have the following lines
Dim t As Type = GetType(MyType)
Dim serialiser As New XmlSerializer(t)
I want to be able to do the following with a FileStream fs
Dim instance As MyType
instance = CType(serialiser.Deserialize(fs), MyType)
but replacing MyType with something more generic, for example
instance = CType(serialiser.Deserialize(fs), t)
Obviously, this does not compile, but could someone tell me what I should
put as the second parameter to CType to make it work? I have tried all
sorts, but just get a selection of compile time errors.
The object of the excercise is to have a shared method of a base class that
deserialises (and serialises) the class.
TIA
Charles
Dim t As Type = GetType(MyType)
Dim serialiser As New XmlSerializer(t)
I want to be able to do the following with a FileStream fs
Dim instance As MyType
instance = CType(serialiser.Deserialize(fs), MyType)
but replacing MyType with something more generic, for example
instance = CType(serialiser.Deserialize(fs), t)
Obviously, this does not compile, but could someone tell me what I should
put as the second parameter to CType to make it work? I have tried all
sorts, but just get a selection of compile time errors.
The object of the excercise is to have a shared method of a base class that
deserialises (and serialises) the class.
TIA
Charles