Beispiel #1
0
        static void Main(string[] args)
        {
            var random = new Random();
            var list   = new ListRandom();

            var list1 = new ListRandom();

            for (int i = 0; i < 20; i++)
            {
                list.Add(random.Next(0, 100));
            }

            Console.WriteLine(list.ToJSON());

            using (FileStream fs = File.Open("list.txt", FileMode.Create))
            {
                list.Serialize(fs);
            }


            using (FileStream fs = File.Open("list.txt", FileMode.Open))
            {
                list1.Deserialize(fs);
            }

            Console.WriteLine(list1.ToJSON());
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            var node1 = new ListNode()
            {
                Data = "1"
            };
            var node2 = new ListNode()
            {
                Data = "2"
            };
            var node3 = new ListNode()
            {
                Data = "3"
            };
            var node4 = new ListNode()
            {
                Data = "4"
            };

            var firstList = new ListRandom(node1);

            firstList.Add(node2);
            firstList.Add(node3);
            firstList.Add(node4);

            using (FileStream fs = new FileStream("list.txt", FileMode.Create))
            {
                firstList.Serialize(fs);
            }

            var secondList = new ListRandom();

            using (FileStream fs = new FileStream("list.txt", FileMode.Open))
            {
                secondList.Deserialize(fs);
            }

            Console.WriteLine("firstList \t secondList");
            for (int i = 0; i < firstList.Count; i++)
            {
                Console.WriteLine("data:{0} \t {1}", firstList.Get(i).Data, secondList.Get(i).Data);
                Console.WriteLine("rand:{0} \t {1}", firstList.Get(i).Random.Data, secondList.Get(i).Random.Data);
            }

            Console.ReadLine();
        }