With these classes. How would I add a new widget with a few components? The Component cannot be a List< Component> as the real world models are from a web service that has that structure. I've done this using a List but when I try and add the 'Widget' class to the models further up the chain it doesn't work as expected
public class Widget
{
public int Id {get; set; }
public string Name { get; set; }
public Part[] parts { get; set; }
}
public class Part
{
public int Id { get; set; }
public string Name { get; set; }
}
Widget widget = new Widget {
Id = 1,
Name = TheWidget
};
foreach(var c in SomeArray)
{
Part part = new Part()
{
component.Id = c.Id,
component.Name = c.Name
}
// Add component to widget
}