I am using BinaryFormatter to serialize a class and its variables by condition. For example:
[Serializable]
public class Class1
{
private Class2 B;
...
}
[Serializable]
public class Class2{...}
I want the variable B to be serialized only when remoting time, but not when i serialize it to file storage.
Questions:
1) I know that in XmlSerialization we can use [XmlIgnore] and {PropertyName}Specified to ignore the property conditionally. Is that a equivalent method for [NonSerialized]?
2) For a class with [Serializable] attribute, how to ignore it at the runtime?