Binary Serialization of a class with a field that has been XmlSerialized

E

erxuan

Hi,
I need to serialize a class A into byte[] and it has a field of type
class B.
Class B is serializable using XML serializer. All the other fields in
class A are of type int.

Do I need to do any changes to class B in order to make an object of
class A serializable using BinaryFormatter?

[Serializable]
class A
{
private B field1;
private int field2;
}
 
P

Pavel Minaev

Hi,
I need to serialize a class A into byte[] and it has a field of type
class B.
Class B is serializable using XML serializer. All the other fields in
class A are of type int.

Do I need to do any changes to class B in order to make an object of
class A serializable using BinaryFormatter?

Whether B is XmlSerializer-compliant (or aware) or not is absolutely
irrelevant. XML and binary serialization are orthogonal - they do not
know about each other, do not use the same interfaces or attributes,
etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top