private List<Freight> freights;
public Truck(string name,double weightCapacity)
{
this.Name = name;
this.WeightCapacity = weightCapacity;
List<Freight> freights = new List<Freight>();
}
In this code you are defining a private class-level variable called "freights", however in the constructor you are creating a second variable called freights and assigning a List to that, however that variable only exists within the constructor, the class-level "freights" is still null.
sb.Append(string.Join(", ", freights)).Append(Freight.ToString());
You can only call "ToString" on an instance of a type;
Freight f = new Freight();
f.ToString();
Freight.ToString();
I suspect you can just remove this ToString and have only this
sb.Append(string.Join(", ", freights));
What this code is going to do is go through each item in freights and call ToString() on it to convert that item to a string, and then comma separate the list. As long as you have a ToString override on the Freight class as well then that code will probably get you what you want.