"Andrew E Chapman" <An************ @discussions.mi crosoft.com> wrote in
message news:DE******** *************** ***********@mic rosoft.com...
sub DeserializeThin g(byval fileName as string, byval T as Thing)
T = DirectCast(bf.D eserialize(fs), Thing)
end sub
DeserializeThin g(FileNameB, AThing)
' Is AThing completely reconstituted ... ?
It certainly should /not/ be, because AThing is passed ByVal to the
method and yes; I realise it's an reference type.
The deserialisation creates a new instance of a Thing object, and
this is assigned to the /local/ variable T, i.e. a "pointer" to the new
object is stored in T. Because you're only passing the "pointer" to
AThing by value, you're method /can't/ assign a value to it, i.e. you
can't "throw away" the current instance in AThing and replace it with
a new one, which is what you're trying to do, and why your object
"seems" to be retaining it's previous values - it is!!
Pass your Thing (ooh, err, missus) into the method ByRef, and you'll
be able to "return" the new, deserialised instance of the object "into"
AThing.
Better still, make this method into a function and return the new
object explicitly, as in
Function DeserializeThin g(byval fileName as string) as Thing
T = DirectCast(bf.D eserialize(fs), Thing)
Return T
End Function
.. . .
AThing = DeserializeThin g( "file" )
HTH,
Phill W.