本文整理汇总了C#中Product.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# Product.ToList方法的具体用法?C# Product.ToList怎么用?C# Product.ToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Product
的用法示例。
在下文中一共展示了Product.ToList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
CountryVatTax[] countries = new CountryVatTax[]
{
new CountryVatTax(1, 0.31, true),
new CountryVatTax(2, 0.21, false),
new CountryVatTax(3, 0.15, false),
new CountryVatTax(4, 0.19, false),
new CountryVatTax(5, 0.32, false),
new CountryVatTax(6, 0.43, false)
};
TaxCalculator calc = new TaxCalculator(countries.ToList());
Product[] products = new Product[]
{
new Product("Juice" , 1, 1, 2, 0.7, calc),
new Product("Cola" , 2, 1, 3, 2.5, calc),
new Product("Vodka" , 3, 1, 6, 3.4, calc),
new Product("Water" , 4, 1, 2, 0.5, calc),
new Product("Wiskey" , 5, 1, 4, 4.3, calc),
new Product("Wine" , 6, 1, 3, 3.2, calc)
};
ShopInventory shop = new ShopInventory(products.ToList());
Dictionary<int, int> items1 = new Dictionary<int, int>();
items1.Add(2, 2);
items1.Add(3, 3);
items1.Add(5, 1);
Order order1 = new Order(items1);
Dictionary<int, int> items2 = new Dictionary<int, int>();
items2.Add(1, 1);
items2.Add(4, 1);
items2.Add(2, 1);
Order order2 = new Order(items2);
Dictionary<int, int> items3 = new Dictionary<int, int>();
items3.Add(6, 4);
items3.Add(5, 1);
items3.Add(3, 2);
Order order3 = new Order(items3);
try
{
Console.WriteLine("Audit: {0}", shop.Audit());
Console.WriteLine("Order 1 value: {0}", shop.RequestOrder(order1));
Console.WriteLine("Audit: {0}", shop.Audit());
Console.WriteLine("Order 2 value: {0}", shop.RequestOrder(order2));
Console.WriteLine("Audit: {0}", shop.Audit());
Console.WriteLine("Order 3 value: {0}", shop.RequestOrder(order3));
}
catch (Exception ex)
{
Console.WriteLine("Error: {0}", ex.Message);
}
Console.WriteLine("Audit: {0}", shop.Audit());
}
示例2: Main
static void Main(string[] args)
{
CountryVatTax[] countries = new CountryVatTax[]
{
new CountryVatTax(1, 0.2, true),
new CountryVatTax(2, 0.3, false),
new CountryVatTax(3, 0.22, false),
new CountryVatTax(4, 0.17, false),
new CountryVatTax(5, 0.43, false),
new CountryVatTax(6, 0.13, false)
};
TaxCalculator calc = new TaxCalculator(countries.ToList());
Product[] products = new Product[]
{
new Product("Hlqb" , 1, 1, 7, 0.8, calc),
new Product("Sirene", 2, 1, 3, 4.5, calc),
new Product("Voda" , 3, 1, 5, 0.4, calc),
new Product("Qica" , 4, 1, 10, 0.1, calc),
new Product("Emeka" , 5, 1, 2, 2.5, calc),
new Product("Sok" , 6, 1, 1, 2.2, calc)
};
ShopInventory shop = new ShopInventory(products.ToList());
Dictionary<int, int> items1 = new Dictionary<int, int>();
items1.Add(2, 2);
items1.Add(3, 3);
items1.Add(1, 2);
Order order1 = new Order(items1);
Dictionary<int, int> items2 = new Dictionary<int, int>();
items2.Add(4, 8);
items2.Add(5, 1);
items2.Add(3, 1);
Order order2 = new Order(items2);
Dictionary<int, int> items3 = new Dictionary<int, int>();
items3.Add(2, 1);
items3.Add(5, 1);
items3.Add(3, 2);
Order order3 = new Order(items3);
try
{
Console.WriteLine("Audit: {0}", shop.Audit());
Console.WriteLine("Order 1 value: {0}", shop.RequestOrder(order1));
Console.WriteLine("Audit: {0}", shop.Audit());
Console.WriteLine("Order 2 value: {0}", shop.RequestOrder(order2));
Console.WriteLine("Audit: {0}", shop.Audit());
Console.WriteLine("Order 3 value: {0}", shop.RequestOrder(order3));
}
catch (Exception ex)
{
Console.WriteLine("Error: {0}", ex.Message);
}
Console.WriteLine("Audit: {0}", shop.Audit());
Console.ReadKey();
}