2

http://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-apiのコード サンプルを見ています。

演習として、C# から vb.net に変換しようとしていますが、この作品ではうまくいきません。

    public class Product
        {
            public int Id { get; set; }
            public string Name { get; set; }
            public string Category { get; set; }
            public decimal Price { get; set; }
    }
     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 } 
            };

私は試した

      Public class Product
         Public Property Id As Integer
         Public Property Name As String
         Public Property Category As String
         Public Property price As Decimal
      End Class

    Dim products() As 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 ) }

配列の代わりにリストを使用するという推奨事項を見たので、それを試してみますが、ここで何が欠けているのか知りたいです。

4

1 に答える 1