I have an object that upon instantiation greats a unique id for itself via the co开发者_Python百科nstructor. My question may be silly but I cannot seem to find the answer.
Will the constructor be called upon rehydration from isolated storage? or is the constructor only called when using the 'new' keyword. My intention is not to have it called as I only want it to be called when instantiating for the first time.
The default constructor will be called during the deserialization process. It will create the object and then copy over the serialized properties/fields.
Although this is for .Net 4, not Silverlight, according to MSDN: ISerializable Interface, specifically:
The ISerializable interface implies a constructor with the signature constructor (SerializationInfo information, StreamingContext context). At deserialization time, the current constructor is called only after the data in the SerializationInfo has been deserialized by the formatter. In general, this constructor should be protected if the class is not sealed.
... I wouldn't expect anything different on the Windows Phone.
精彩评论