序列化程序會將物件轉換成位元組資料流,以將物件儲存或傳輸到記憶體、資料庫或檔案。 其主要目的是儲存物件的狀態,這樣就能在需要時重新建立該物件。 反向的程序則稱為還原序列化。
圖片來源: 微軟文件
The object is serialized to a stream that carries the data. The stream may also have information about the object's type, such as its version, culture, and assembly name. From that stream, the object can be stored in a database, a file, or memory.
序列化的用法
序列化可讓開發人員儲存物件的狀態,並視需要重新建立物件,以提供物件和資料交換的儲存體。 透過序列化,開發人員可以執行下列動作:
使用 web 服務將物件傳送到遠端應用程式