zoukankan      html  css  js  c++  java
  • <C#>序列化

    序列化就是为了简化复杂的数据结构的存储提出来的概念。

    序列化也就是把类的对象作为一个整体存入文件,反序列化则是相反过程

    #using System;
    #using System.IO;
    #using System.Collections.Generic;
    #using System.Runtime.Serialization.Formatters.Binary;
    #using System.Runtime.Serialization;
    
    class SerialFile
    {
        static void Main()
       {
                 Dictionary<string,string>  h = new Dictionary<string,string>();
                 h.Add("Key1","Value1");
                 h.Add("Key2","Value2");
                 FileStream fs = new FileStream(@"d:/d.dat",FileMode.Create);
                 BinaryFormatter formatter = new BinaryFormatter();
                 formatter.Serialize(fs,h);
                 fs.close();
                 fs = new FileStream(@"d:/d.dat",FileMode.Open);
                 h.Clear();
                 h = (Dictionary<string,string>)formatter.Deserialize(fs);
                 fs.Close();
                 foreach(KeyValuePair<string,string> h1 in h)
                 {
                           Console.WriteLine{"{0}:{1}",h1.Key,h1.Value};
                  }
       }  
    }    
  • 相关阅读:
    kubernetes---Init-Container
    kubernetes---affinity--taint
    kubernetes---pod调度
    kubernetes---项目部署
    StatefulSet
    kubernetes---存储--PV--PVC
    pod-pod控制器-service-ingress
    jenkins
    django中的验证码
    django中的缓存
  • 原文地址:https://www.cnblogs.com/virgil/p/3841688.html
Copyright © 2011-2022 走看看