这是数组列表还是方法或数组对象
Is this a list of array or a method or array object
我正忙于通过 MSDN 文档学习如何实现 Web API,只是想知道下面这段代码的含义,因为它让我感到困惑;特别是 Product[] products = new Product[]
products 对象从何而来,为什么它有 [ ] 之类的数组?
是数组列表还是方法还是对象数组?
取自 MSDN here
Product[] products = new Product[]
{
new Product { Id = 1, Name = "Tomato Soup", Category = "Groceries", Price = 1 },
new Product { Id = 2, Name = "Yo-yo", Category = "Toys", Price = 3.75M },
new Product { Id = 3, Name = "Hammer", Category = "Hardware", Price = 16.99M }
};
这是一个包含 Product 个对象的数组。
我正忙于通过 MSDN 文档学习如何实现 Web API,只是想知道下面这段代码的含义,因为它让我感到困惑;特别是 Product[] products = new Product[]
products 对象从何而来,为什么它有 [ ] 之类的数组?
是数组列表还是方法还是对象数组?
取自 MSDN here
Product[] products = new Product[]
{
new Product { Id = 1, Name = "Tomato Soup", Category = "Groceries", Price = 1 },
new Product { Id = 2, Name = "Yo-yo", Category = "Toys", Price = 3.75M },
new Product { Id = 3, Name = "Hammer", Category = "Hardware", Price = 16.99M }
};
这是一个包含 Product 个对象的数组。