物件序列化

2021-06-22 09:34:26 字數 489 閱讀 5757

物件序列化

1:首先該物件要實現serializable的介面

public class person implements serializable

public void setname(string name)

}

2:將物件序列化到乙個檔案中(當然你也可以序列化到其他地方)

public class persontest  catch (ioexception e)  finally catch (ioexception e) 

}} }

}

3:從檔案中將物件取出

public class persontest2  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...