Given the following class structure, will Bar serialize/deserialize as expected?
public class Foo { int x; string y; }
[Serializable]
public class Bar {
Foo[] AllFoos;
Foo SelectedFoo;
public Bar(Foo[] allFoos, int selectedFooIndex) {
this.AllFoos = allFoos;
this.SelectedFoo = allFoos[selectedFooIndex];
}
}
I'm curious about a couple of things:
1) Does the BinaryFormatter REQUIRE that the Bar class be decorated with the [Serializable] attribute or implement the ISerializable interface?
2) Does the Foo class also need to be decorated with the [Serializable] attribute?
3) If Bar is simply decorated with the [Serializable] attribute, will the field Bar.SelectedFoo maintain its reference into the array correctly? or will I wind up with a copy of that Foo?