While I don't have a hard requirement for this, I'd like to manipulate all elements of a list except for the last one. For example, assume a class Cars
public class Car {
public string Name { get; set; }
public List<Tire> Tires { get; set; }
}
var cars = _db.GetAllCars().Select(x => new Car {
Name = x.Name + ", ",
Tires = x.Tires
});
This works, except the last element in the list will have a comma, which I don't want ... but I still want the last item in the list. I cannot so a simple string.Join as I'm passing this to a view which has a lot of template code around the Name element. Is what I'm trying to do possible?