예제 #1
0
 public static void ShowAll(CsvReaderDictionary csvReaderDictionary)
 {
     Console.Clear();
     foreach (var item in csvReaderDictionary.ReadAllCountries().Values)
     {
         Console.WriteLine(item.Name.PadRight(30, ' ') + " " + item.Region.PadRight(30, ' ') + " " + item.Code.PadRight(30, ' ') + " " + item.Population);
     }
 }
예제 #2
0
        static void Main(string[] args)
        {
            string path = @"C:\Users\NDM\Downloads\country.csv";
            CsvReaderDictionary csvReaderDictionary = new CsvReaderDictionary(path);
            int count = 0;

            foreach (var item in csvReaderDictionary.ReadAllCountries().Values)
            {
                if (count < 5)
                {
                    Console.WriteLine(item.Name.PadRight(30, ' ') + " " + item.Region.PadRight(30, ' ') + " " + item.Code.PadRight(30, ' ') + " " + item.Population);
                    count++;
                }
            }

            int number;

            do
            {
                Console.WriteLine("                               ____________________________________________________");
                Console.WriteLine("                              |             Please select an option:               |");
                Console.WriteLine("                              |                                                    |");
                Console.WriteLine("                              |             1.Insert number of countries display   |");
                Console.WriteLine("                              |             2.Insert number add countries          |");
                Console.WriteLine("                              |             3.Show All                             |");
                Console.WriteLine("                              |____________________________________________________|");
                Console.Write("                                           Option:");
                string option = Console.ReadLine();
                number = ValidatedData.CheckNumberInt(option);
                switch (number)
                {
                case 1:
                    InsertDisplay(csvReaderDictionary);
                    break;

                case 2:
                    break;

                case 3:
                    ShowAll(csvReaderDictionary);
                    break;
                }
            } while (number != 4);
        }
예제 #3
0
        public static void InsertDisplay(CsvReaderDictionary csvReaderDictionary)
        {
            int number = 1;

            Console.Write("Input Number of countries:");
            string abc     = Console.ReadLine();
            int    number2 = ValidatedData.CheckNumberInt(abc);

            Console.Clear();
            foreach (var item in csvReaderDictionary.ReadAllCountries().Values)
            {
                if (number % number2 == 0)
                {
                    Console.ReadKey();
                    Console.Clear();
                }
                Console.WriteLine(item.Name.PadRight(30, ' ') + " " + item.Region.PadRight(30, ' ') + " " + item.Code.PadRight(30, ' ') + " " + item.Population);
                number++;
            }
        }