1) BinaryFormatter 是否要求 Bar 类用 [Serializable] 属性装饰或实现 ISerializable 接口?
是的,如果要使用 BinaryFormatter 序列化 Bar 实例,它确实如此。
2) Foo 类是否也需要用 [Serializable] 属性装饰?
Yes, unless you create a custom serialization mechanism that does not involve serializing an instance of a Foo object. For example, you could serialize the x and y components separately, and create a new Foo instance from them in your deserialization code. Otherwise, it must have the attribute or interface.
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?
If I remember correctly, arrays are not serializable like this. You must provide your own mechanism (through the ISerializable inteface) for writing and reading arrays.
However, in general, if a graph of serializable objects with mutual references to each other is serialized with the BinaryFormatter, then it will recreate the references correctly without duplicating objects. This should include objects that you specify in your custom serialization code as well, so long as you decorate your Foo with Serializable and pass the same object instance to the formatter from both the array and the field.