SessionStateItemCollection.Serialize(BinaryWriter) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將集合的內容寫入 BinaryWriter。
public:
void Serialize(System::IO::BinaryWriter ^ writer);
public void Serialize (System.IO.BinaryWriter writer);
member this.Serialize : System.IO.BinaryWriter -> unit
Public Sub Serialize (writer As BinaryWriter)
參數
- writer
- BinaryWriter
BinaryWriter,用於將序列化集合寫入資料流或編碼字串。
範例
下列程式碼範例會建立並填入 SessionStateItemCollection 集合,並使用 方法將內容寫入檔案 Serialize 。
SessionStateItemCollection items = new SessionStateItemCollection();
items["LastName"] = "Wilson";
items["FirstName"] = "Dan";
System.IO.BinaryWriter writer = new System.IO.BinaryWriter(
System.IO.File.Open(Server.MapPath("session_collection.bin"), System.IO.FileMode.Create));
items.Serialize(writer);
writer.Close();
Dim items As SessionStateItemCollection = New SessionStateItemCollection()
items("LastName") = "Wilson"
items("FirstName") = "Dan"
Dim writer As System.IO.BinaryWriter = New System.IO.BinaryWriter( _
System.IO.File.Open(Server.MapPath("session_collection.bin"), System.IO.FileMode.Create))
items.Serialize(writer)
writer.Close()
備註
Serialize方法可用來將集合的內容 SessionStateItemCollection 寫入會話存放區。
若要從會話存放區擷取序列化 SessionStateItemCollection 物件,請使用 Deserialize 方法。
適用於
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應