[英]I am getting this error while placing data from data table into chart
cs1503 argument 1 cannot convert from 'system.collections.generic.list <<annonymous type:string CustomerEmail,string Count>>' to "System.Collections.GenericList<Coursework.Customer> cs1503 参数 1 无法从 'system.collections.generic.list <<annonymous type:string CustomerEmail,string Count>>' 转换为 "System.Collections.GenericList<Coursework.Customer>
You must map the data in the two tables together.您必须将两个表中的数据 map 放在一起。 For example, you have a product table and the product has a name and price.例如,您有一个产品表,产品有名称和价格。 And you want to turn the product into a car table and the car has a name and a price.你想把产品变成汽车桌,汽车有名字和价格。 Therefore, you assign the name and price of the product to the name and price of the car table.因此,您将产品的名称和价格分配给汽车表的名称和价格。
public class Product
{
public string ProductName { get; set; }
public string Price { get; set; }
}
public class Car
{
public string CarName { get; set; }
public string Price { get; set; }
}
List<Product> products = new List<Product>()
{
new Product(){ProductName = "Car1", Price = "1,000,000"},
new Product(){ProductName = "Car2", Price = "1,000,000"},
new Product(){ProductName = "Car3", Price = "1,000,000"},
};
List<Car> cars = new List<Car>();
foreach (var item in products)
{
Car car = new Car();
car.CarName = item.ProductName;
car.Price = item.Price;
cars.Add(car);
}
//You can now use this list...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.