public Aeroflot[] SortFlightsArrDescending(Aeroflot[] flights)//sorts array descendingly by flight number
 {
     try
     {
         if (flights.Length == 0)
         {
             throw new Exception("Array is empty, nothing to sort");
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     for (int i = 0; i < flights.Length - 1; i++)
     {
         for (int j = i + 1; j < flights.Length; j++)
         {
             if (flights[i]._flightNum < flights[j]._flightNum)
             {
                 Aeroflot temp = flights[j];
                 flights[j] = flights[i];
                 flights[i] = temp;
             }
         }
     }
     return(flights);
 }
 public Aeroflot[] FlightsArr(Aeroflot obj, int size)//returns filled array
 {
     Aeroflot[] flights = new Aeroflot[size];
     try
     {
         flights[0] = obj;//assigning created object as 0 element so it won't be useless
         FillAeroflot(flights[0]);
     }
     catch (IndexOutOfRangeException ex)
     {
         Console.WriteLine(ex.Message);
     }
     for (int i = 1; i < flights.Length; i++)
     {
         flights[i] = new Aeroflot();
         FillAeroflot(flights[i]);
     }
     return(flights);
 }
        static void Main(string[] args)
        {
            int size;

            Console.Write("Enter array size: ");
            size = int.Parse(Console.ReadLine());
            Aeroflot qwerty = new Aeroflot();

            Aeroflot[] qwertyArr = new Aeroflot[size];//creating new array to hold array which is returned from FlightsArr function
            qwertyArr = qwerty.FlightsArr(qwerty, size);
            qwerty.ShowFlightsArr(qwertyArr);

            qwerty.SortFlightsArrDescending(qwertyArr);
            Console.WriteLine("\nArray sorted by flight number:");
            qwerty.ShowFlightsArr(qwertyArr);

            string destination;

            Console.Write("\nEnter desired destination: ");
            destination = Console.ReadLine();
            qwerty.ShowMatchedFlights(qwertyArr, destination);
        }
        private Aeroflot FillAeroflot(Aeroflot obj)//fills empty object with respective values (constructor-ish)
        {
            bool tryAgain = true;

            do
            {
                try
                {
                    Console.Write("Enter destination: ");
                    obj._destination = Console.ReadLine();
                    Console.Write("Enter flight №: ");
                    obj._flightNum = int.Parse(Console.ReadLine());
                    Console.Write("Enter plane type: ");
                    obj._planeType = Console.ReadLine();
                    tryAgain       = false;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            } while (tryAgain);
            return(obj);
        }