简体   繁体   English

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

[英]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.

相关问题 从solr获取数据时,我遇到了错误 - while getting data from solr, i am having the error blow 从表中读取数据时出现错误 - Getting Error while read the data from table 使用iTextSharp从PDF文件提取文本时,出现此错误:“找不到图像数据或EI” - While extracting text from PDF file using iTextSharp, I am getting this error: “Could not find image data or EI” 使用iTextSharp从PDF文件提取文本时,出现此错误:“找不到图像数据或EI” - While extracting text from PDF file using iTextSharp, I am getting this error: “Could not find image data or EI” 将数据上传到本地数据库时,出现一个错误,提示“对象必须实现可转换” - While uploading data to my local database i am getting an error called “Object must implement convertible” 为什么在尝试从XML文件读取数据时出现Null Referenfe异常? - Why am I getting Null Referenfe exception while trying to read data from XML file? 从 Twitter 获取公共数据时出错 - Error while getting public data from twitter 从NavigationContext获取数据时出错 - Error while getting data from NavigationContext 我将选定的数据从一个列表框移动到另一个列表框,但出现错误“对象引用未设置为对象的实例”。 - I am moving selected data from one listbox to another but I am getting an error “Object reference not set to an instance of an object.” 我收到一个错误,我正在表单标题而不是文本框中获取数据 - I am getting an error that I am getting data in Form header instead of textbox
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM