public class Product { /// <summary> /// 自增ID /// </summary> public int ID { get; set; } /// <summary> /// 主键 /// </summary> public string Code { get; set; } /// <summary> /// 名称 /// </summary> public string Name { get; set; } /// <summary> /// 类型 /// </summary> public string Category { get; set; } /// <summary> /// 价格 /// </summary> public decimal Price { get; set; } /// <summary> /// 生产日期 /// </summary> public DateTime ProduceDate { get; set; } public override string ToString() { return string.Format("{0}{1}{2}{3}{4}{5}", ID.ToString().PadLeft(2), Category.PadLeft(15), Code.PadLeft(7), Name.PadLeft(17), Price.ToString().PadLeft(4), ProduceDate.ToString("yyyy-M-d").PadLeft(13)); } public static ProductCollection GetSampleCollection() { ProductCollection collection = new ProductCollection( new Product() { ID = 1, Code = "1001", Category = "Red Wine", Name = "Product1" } , new Product() { ID = 2, Code = "1002", Category = "Red Wine", Name = "Product2" } , new Product() { ID = 3, Code = "1003", Category = "Red Wine", Name = "Product3" } , new Product() { ID = 4, Code = "1004", Category = "Red Wine", Name = "Product4" } , new Product() { ID = 5, Code = "1005", Category = "Red Wine", Name = "Product5" } , new Product() { ID = 6, Code = "1006", Category = "Red Wine", Name = "Product6" } , new Product() { ID = 7, Code = "1007", Category = "Red Wine", Name = "Product7" } ); return collection; } }
相关文章: