예제 #1
0
        //https://docs.microsoft.com/en-us/dotnet/standard/serialization/basic-serialization

        static void Main(string[] args)
        {
            MyObject obj = new MyObject();

            obj.n1  = 1;
            obj.n2  = 24;
            obj.str = "Some String";

            IFormatter formatter = new BinaryFormatter();
            Stream     stream    = new FileStream("MyFile.bin",
                                                  FileMode.Create, FileAccess.Write, FileShare.None);

            formatter.Serialize(stream, obj);
            stream.Close();

            Console.WriteLine("n1: {0}", obj.n1);
            Console.WriteLine("n2: {0}", obj.n2);
            Console.WriteLine("str: {0}", obj.str);

            ValueTuple <string, DateTime, decimal, int> value =
                ValueTuple.Create("03244562", DateTime.Now, 13452.50m, 45);

            value.CountTuples();

            value.IsSerializable();
            Console.ReadKey();
        }