//ProductAttribute有三个属性 class ProductAttribute { string name = ""; float price = 0; int number = 0; public ProductAttribute(string name, float price, int number) { this.name = name; this.price = price; this.number = number; } //对list进行初始化 List<ProductAttribute> productList; productList = new List<ProductAttribute>() { new ProductAttribute("apple",(float)1.11,0), new ProductAttribute("banana",(float)2.22,0), new ProductAttribute("orange",(float)3.33,0), new ProductAttribute("pear",(float)4.44,0), new ProductAttribute("lemon",(float)5.55,0), new ProductAttribute("mango",(float)6.66,0), new ProductAttribute("grape",(float)7.77,0), new ProductAttribute("coconut",(float)8.88,0), new ProductAttribute("litchi",(float)9.99,0) };
原文:http://www.cnblogs.com/tt-1025/p/5132910.html