static double GetVehiclesCapacity(VehicleList garage) { MethodInfo methodInfo = garage.GetType().GetMethod("CountVehiclesLoadCapacity", new Type[] { typeof(List <Vehicle>) }); double sumOfcapacity = (double)methodInfo.Invoke(garage, new object[] { garage.Vehicles }); return(sumOfcapacity); }
static void Main(string[] args) { Console.WriteLine("Graczyk Kamil, 246994"); Console.WriteLine($"{Environment.MachineName}\n"); VehicleList garage = new VehicleList(); garage.Vehicles.AddRange(GetVehiclesList()); double result = GetVehiclesCapacity(garage); WriteLine("\nŁączna nośćność pojazdów: " + result); }