1
我剛剛熟悉C#中對象的序列化。我想知道如果反序列化構造函數被稱爲INSTEAD的默認構造函數或IN ADDITION TO。如果它是IN ADDITION TO,這些調用的順序是什麼?例如:C#反序列化構造函數是否調用默認構造函數的INSTEAD?
[Serializable()]
public class ReadCache : ISerializable
{
protected ArrayList notifiedURLs;
// Default constructor
public ReadCache()
{
notifiedURLs = new ArrayList();
}
// Deserialization constructor.
public ReadCache(SerializationInfo info, StreamingContext ctxt)
{
//Get the values from info and assign them to the appropriate properties
notifiedURLs = (ArrayList)info.GetValue("notifiedURLs", typeof(ArrayList));
}
}
Gotcha。何時:使用this()時,哪個代碼先執行?默認的構造函數代碼或反序列化構造函數代碼? – Doug 2012-03-12 06:56:24
部分在你的「默認」 - 構造 - 想一想,不是很有用,否則不是嗎? – Carsten 2012-03-12 06:59:46
非常感謝。 – Doug 2012-03-12 07:01:08