物件的序列化2

2021-06-22 09:36:29 字數 623 閱讀 7610

能在特殊的要求下對物件的序列化進行特殊的操作

1:實現externalizable介面

public class student implements externalizable 

public string getname()

public void setname(string name)

// 序列化的時候會自動呼叫這個方法

@override

public void writeexternal(objectoutput out) throws ioexception

// 反序列化的時候會自動呼叫這個方法

@override

public void readexternal(objectinput in) throws ioexception,

classnotfoundexception

}

2:進行序列化操作

public class studenttest  catch (exception e) finally catch (ioexception e) 

}}

}}

物件序列化 反序列化

必須新增引用 using system.io using system.runtime.serialization using system.runtime.serialization.formatters.binary 方法 region 物件序列化 物件序列化 任意物件 字串 public st...

物件 序列化 反序列化

public class eventmessage 資訊提示類 型別1 操作日誌2 安全日誌 標題 內容 icon型別 url 執行script指令碼字串 需加 public static void messagebox int m type,string m title,string m body...

物件序列化

using system using system.io using system.diagnostics using system.reflection using system.runtime.serialization using system.runtime.serialization.fo...