Actually I had in mind a binary serialization: I would like to try both
to see which one is faster (whithout trying,I would assume binary
should be better).
Actually this is a fundamental issue in programming, and as Cor has
sugested, it can take months to fully master all the subtleties.
Assume for instance you have an object which has the property (an
object) "Kind". Assume you have 100 of these objects stored in an
arraylist. Assume that there are only 5 kinds fo "Kind" objects which
are themseles stored in another arraylist, say "Kinds".
When you serialize and deserialize the arraylist with the 100 objects
and the arraylist with the 5 Kinds, you lose the referential equality
of the Kinds. You will have 100 objects each with its "Kind" and each
of these is a different reference from the 5 deserialized "Kinds" that
are in the arraylist od the Kinds. So you will need to relink them...
This is just one example. One really has to get well organized
(creating interfaces and precise rules to jerarchically restore
objects) to deal with that effectively in real world application...
Let me know if you compare the 2 types of serializations...
tom
Cor Ligthert [MVP] ha scritto:
OpticTygre,
This is difficult to explain because there is no standard.
Most Copy methods are shalow copies. The pointers of its members are copied.
The CopyTo method is a copy method, however is not everywhere.
The Copy from a datatable and a dataset object is a real copy as well as the
GetChanges in that object.
To copy an object completely you can serialize and deserialize it.
Here a sample with an arraylist. (the class has to be serializable)
http://www.vb-tips.com/default.aspx?...c-61641f5c8d9d
Be aware that although this are few instructions it takes time.
I hope this helps,
Cor
"OpticTygre" <op********@adelphia.net> schreef in bericht
news:G5******************************@adelphia.com ... If I pass an object to another form via the new form's tag property, I
want to create an object exactly like it, with it's properties and all,
but have it be a copy of the object passed through, and not just a
reference to the object.
Example:
Public Sub Form_Load(ByVal sender as Object, ByVal e as EventArgs)
Dim obj as Object = Activator.CreateInstance(Me.Tag.GetType())
obj = Me.Tag
When I say that obj = Me.Tag, then it only provides a reference to the
object in the Tag property. How can I create an exact duplicate instead?
TIA,
-Jason