How does BinaryFormatter.Deserialize create new objects?
问题 When BinaryFormatter deserializes a stream into objects, it appears to create new objects without calling constructors. How is it doing this? And why? Is there anything else in .NET that does this? Here's a demo: [Serializable] public class Car { public static int constructionCount = 0; public Car() { constructionCount++; } } public class Test { public static void Main(string[] args) { // Construct a car Car car1 = new Car(); // Serialize and then deserialize to create a second, identical car