static double GetCarHandlerVehiclesCapacity(CarHandler carHandler) { MethodInfo methodInfo = carHandler.GetType().GetMethod("CountTotalVehiclesLoadCapacity", new Type[] { typeof(List <Vehicle>) }); double sumOfcapacity = (double)methodInfo.Invoke(carHandler, new object[] { carHandler.Vehicles }); return(sumOfcapacity); }
static void Main(string[] args) { PrintInfo(); CarHandler carHandler = new CarHandler(); carHandler.Vehicles.AddRange(GetVehiclesList()); double result = GetCarHandlerVehiclesCapacity(carHandler); WriteLine($"Total load capacity: {result}"); }