I have a list of a certain type which looks like this:
class DestinationType {
public string FruitName { get; set; }
public string VegetableName { get; set; }
}
What I want to do is create a list of the above type DestinationType
and add elements to it from two different List of type string. The lists that have the values that I want to add to DestinationType looks like the ones below:
fruitList = List<string> { "apple", "orange" }
vegetableList = List<string> { "celery", "pumpkin" }
How can I add the elements from fruitList
and vegetableList
such that the end result would look like the one here?
List<DestinationList> theCompleteDestinationItem =
[
{
fruitName: "apple",
vegetableName: "celery"
},
{
fruitName: "orange",
vegetableName: "pumpkin"
}
]