Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在将数据表中的数据放入图表时出现此错误_C#_Winforms - Fatal编程技术网

C# 在将数据表中的数据放入图表时出现此错误

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 {

cs1503参数1无法从“system.collections.generic.list”转换为“System.Collections.GenericList

您必须将两个表中的数据映射到一起。例如,您有一个产品表,产品有名称和价格。你想把产品变成汽车表,汽车有名字和价格。因此,将产品的名称和价格指定给car表的名称和价格

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
对象(或返回枚举的对象)。没有代码,很难帮助你。我更新了代码没有,你没有。我可以发邮件给你吗?你可以简单地把这个问题粘贴到代码中