Conditional C# Binary Serialization

前端 未结 3 1477
小鲜肉
小鲜肉 2021-01-16 06:32

I am using BinaryFormatter to serialize a class and its variables by condition. For example:

[Serializable]
public class Class1
{
private Class2 B;
...
}

[S         


        
3条回答
  •  执念已碎
    2021-01-16 07:01

    1. There is no such method. You can control serialization by implementing ISerializable, and if you do you will know which serialization context is active (remoting, file etc.)
    2. AFAIK no way to do it, why do you want this?

    Generally speaking I advise you against using BinaryFormatter. It is a maintenance headache if there ever was one. Use XML serialization or some kind of protocol buffers.

提交回复
热议问题