Weird problems with objects deseralizing from XML

  • Thread starter Thread starter Nathan
  • Start date Start date
N

Nathan

I'm a newbie to serializing/deserializing objects to XML... with this
problem being a huge nightmare.

II have object_A and object_B and write "if object_A is object_B then..."
(object_A and object_B are the same type):

- If I've created object_A and object_B through code (Dim object_A as ...)
the above statement will be evaluated as true
- If object_A and object_B have been deserialized from XML, it will be false
(even though both object_A and object_B are the same type)

Why would this problem be occurring? Even though in both cases both objects
are the same type, it seems there is some problem with from where the object
was created.

I can post my code if this isn't clear :)
 
Nathan said:
Why would this problem be occurring? Even though in both cases both objects
are the same type, it seems there is some problem with from where the object
was created.

The Is operator is used to test if two references are to the same object.
It doesn't test if the objects are of the same type.

Tom
 
Ahh... hence my problem.

The reason I was using 'is' was to find an object within a collection.
Instead, how would I accomplish this (to retrieve the desired object from
within a collection)?

Thanks Tom for that pointer...
 
Nathan said:
The reason I was using 'is' was to find an object within a collection.
Instead, how would I accomplish this (to retrieve the desired object from
within a collection)?

Hi again,

You are trying to find the same object or one that contains the same values?
If you are looking to find a common reference then I think you stick with Is
but then it shouldn't surprise you that the clone is a different object.

I'm not certain exactly what you searching for of course but if you are
trying to see if you placed an object with a certain value in the collection
I think you'll have to check the value of the property for each object in
the collection.

Tom
 
Back
Top