Beispiel #1
0
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(", ", StringSplitOptions.RemoveEmptyEntries).ToArray();

            var list     = new List <Articals>();
            var articals = new Articals();

            string titele  = input[0];
            string content = input[1];
            string author  = input[2];

            list.Add(articals);

            articals.Titele  = titele;
            articals.Content = content;
            articals.Author  = author;

            int n = int.Parse(Console.ReadLine());

            int counter = 0;

            while (counter != n)
            {
                string[] nextLine = Console.ReadLine().Split(": ", StringSplitOptions.RemoveEmptyEntries).ToArray();

                if (nextLine[0] == "Edit")
                {
                    articals.Content = nextLine[1];
                }
                else if (nextLine[0] == "ChangeAuthor")
                {
                    articals.Author = nextLine[1];
                }
                else
                {
                    articals.Titele = nextLine[1];
                }
                counter++;
            }

            foreach (var item in list)
            {
                Console.WriteLine($"{item.Titele} - {item.Content}: {item.Author}");
            }
        }
        static void Main(string[] args)
        {
            int             n = int.Parse(Console.ReadLine());
            List <Articals> listOfArticals = new List <Articals>();

            for (int i = 0; i < n; i++)
            {
                string[] input = Console.ReadLine().Split(", ");

                var newArtical = new Articals();

                newArtical.Titele  = input[0];
                newArtical.Content = input[1];
                newArtical.Author  = input[2];

                listOfArticals.Add(newArtical);
            }

            string finalComand = Console.ReadLine();

            var result = new List <Articals>();

            if (finalComand == "title")
            {
                result = listOfArticals.OrderBy(x => x.Titele).ToList();
            }
            else if (finalComand == "content")
            {
                result = listOfArticals.OrderBy(x => x.Content).ToList();
            }
            else
            {
                result = listOfArticals.OrderBy(x => x.Author).ToList();
            }

            foreach (var item in result)
            {
                Console.WriteLine($"{item.Titele} - {item.Content}: {item.Author}");
            }
        }