I have several bags, each filled with multiple containers of apples, where each container may have 0 or more apples.
public class Bag
{
public List<Container> Containers { get; set; }
}
public class Container
{
public List<Apple> Apples { get; set; }
}
public class Apple
{
public double Weight { get; set; }
}
If I have a collection List<Bag> bags
, how can I calculate the total weight of all apples via Linq in C#?