While trying to print items in a list after selecting fields from that list, I get an error saying "cannot convert from list to item". Some queries work, but a few, like the one listed below, require a different print void. I'd like it to work without multiple print voids.
I have tried placing the foreach loop directly under the query, but it can't locate the proper items to print.
List<Item> items = new List<Item>();//create list
items.Add(new Item()
{
ItemGroup = "Electric",
ItemDescription = "Electric Sander",
Quantity = 7,
UnitPrice = 59.98f,
});//add list item
var totalValue = items
.Select(x => (
x.ItemDescription,
x.Quantity,
x.UnitPrice,
x.Price = TotalValue((int)x.Quantity, (float)x.UnitPrice)
))
.OrderBy(x => x.Quantity)
.ToList();//create new list for question 1
PrintItems(totalValue);//print item (throwing error "can't
//convert list to item"
static void PrintItems(List<Item> items)//print void
{
foreach (var Item in items)
{
Console.WriteLine("" + Item);
}
}