Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public List<Car> FindNewestCars()
- {
- List<Car> result = new List<Car>();
- DateTime latestDate = allCars[0].BuiltDate;
- foreach (var car in allCars)
- {
- if (DateTime.Compare(latestDate, car.BuiltDate) > 0)
- {
- latestDate = car.BuiltDate;
- }
- }
- foreach (var car in allCars)
- {
- if (DateTime.Compare(latestDate, car.BuiltDate) == 0)
- {
- result.add(car);
- }
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement