zoukankan      html  css  js  c++  java
  • 通过序列化实现深拷贝

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    class App
    {

        public static void Main(string[] args)
        {

            abc abc1 = new abc();
            abc1.a = "a";
            abc1.b = "b";
            abc1.c = "c";
            MemoryStream memoryStream = new MemoryStream();
            BinaryFormatter formatter = new BinaryFormatter();
            formatter.Serialize(memoryStream, abc1);
            memoryStream.Position = 0;
            abc abc2 = (abc)formatter.Deserialize(memoryStream);
            Console.ReadLine();
        }

    }

    [Serializable]
    public class abc
    {
        public string a;
        public string b;
        public string c;
    }

  • 相关阅读:
    DFS-B
    DFS/BFS-A
    DFS-回溯与剪枝-C
    BFS-八数码问题与状态图搜索
    PTA-1003 我要通过!
    二分-G
    二分-F
    二分-E
    二分-D
    二分-C
  • 原文地址:https://www.cnblogs.com/zhuawang/p/2181822.html
Copyright © 2011-2022 走看看