public void RemoveSetOfRegistrationNumber(List <string> registrationNumbers) { foreach (var regPlate in registrationNumbers) { if (ListOfCars.Any(x => x.RegistrationNumber == regPlate)) { Car car = ListOfCars.Find(x => x.RegistrationNumber == regPlate); ListOfCars.Remove(car); } } Count = ListOfCars.Count; }
public string RemoveCar(string registrationNumber) { if (!ListOfCars.Any(x => x.RegistrationNumber == registrationNumber)) { return("Car with that registration number, doesn't exist!"); } else { Car carForRemove = ListOfCars.Find(x => x.RegistrationNumber == registrationNumber); ListOfCars.Remove(carForRemove); Count = ListOfCars.Count; return($"Successfully removed {registrationNumber}"); } }