C# 在将数据表中的数据放入图表时出现此错误
cs1503参数1无法从“system.collections.generic.list”转换为“System.Collections.GenericList您必须将两个表中的数据映射到一起。例如,您有一个产品表,产品有名称和价格。你想把产品变成汽车表,汽车有名字和价格。因此,将产品的名称和价格指定给car表的名称和价格C# 在将数据表中的数据放入图表时出现此错误,c#,winforms,C#,Winforms,cs1503参数1无法从“system.collections.generic.list”转换为“System.Collections.GenericList您必须将两个表中的数据映射到一起。例如,您有一个产品表,产品有名称和价格。你想把产品变成汽车表,汽车有名字和价格。因此,将产品的名称和价格指定给car表的名称和价格 public class Product { public string ProductName { get; set; } public string Price {
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...
公共类产品
{
公共字符串ProductName{get;set;}
公共字符串Price{get;set;}
}
公车
{
公共字符串CarName{get;set;}
公共字符串Price{get;set;}
}
列表产品=新列表()
{
新产品(){ProductName=“Car1”,Price=“1000000”},
新产品(){ProductName=“Car2”,Price=“1000000”},
新产品(){ProductName=“Car3”,Price=“1000000”},
};
列出车辆=新列表();
foreach(产品中的var项目)
{
汽车=新车();
car.CarName=item.ProductName;
car.Price=item.Price;
cars.Add(car);
}
//您现在可以使用此列表。。。
您可能有一个Lambda,它创建了一个匿名类型,而不是一个新的Coursework.Customer
对象(或返回枚举的对象)。没有代码,很难帮助你。我更新了代码没有,你没有。我可以发邮件给你吗?你可以简单地把这个问题粘贴到代码中