Пример #1
0
        static private void ShowObject(ListRandom l)
        {
            Console.WriteLine($"\n************START************");
            Console.WriteLine($"\nCount of list elm-ts: {l.Count}\n");
            var x     = l.Head;
            int count = 1;

            while (true)
            {
                Console.WriteLine($"list node {count}:\n   node.Data = {x.Data};\n   node.Random.Data = {x.Random.Data};\n");
                if (x.Next == null)
                {
                    break;
                }
                x = x.Next;
                count++;
            }
            Console.WriteLine($"");
            Console.WriteLine($"*************END*************\n\n");
        }
Пример #2
0
        static void Main(string[] args)
        {
            ListRandom listOut = new ListRandom();
            ListRandom listIn  = new ListRandom();

            int listSize = random.Next(5, 5);

            for (int i = 0; i < listSize; i++)
            {
                if (random.Next(100) < 50)
                {
                    listOut.addToHead(RandomString());
                }
                else
                {
                    listOut.addToTail(RandomString());
                }
            }

            //listOut.addToHead("one - 1");
            //listOut.addToTail("two - 2");
            //listOut.addToTail("three - 3");

            using (MemoryStream str = new MemoryStream())
            {
                ShowObject(listOut);
                listOut.Serialize(str);

                listIn.Deserialize(str);
                ShowObject(listIn);

                Console.WriteLine("");
            }

            Console.ReadLine();
        }