C# To VB.Net Conversion - array of class objects with initialisation
- by mattryan
can someone help me pls, im new to vb.net and im trying to work through the nhibernate firstsolkution sample (written in c#) and im struggling to convert this one bit. ive tried numerous convertors; telerik, developerfusion and a several others but none of the code produced will compile and i cant see the why...
private readonly Product[] _products = new[]
{
new Product {Name = "Melon", Category = "Fruits"},
new Product {Name = "Pear", Category = "Fruits"},
new Product {Name = "Milk", Category = "Beverages"},
new Product {Name = "Coca Cola", Category = "Beverages"},
new Product {Name = "Pepsi Cola", Category = "Beverages"},
};
developer fusion gives
Private ReadOnly _products As Product() = New () {New Product(), New Product(), New Product(), New Product(), New Product()}
telerik gives
Private ReadOnly _products As Product() = New () {New Product() With { _
.Name = "Melon", _
.Category = "Fruits" _
}, New Product() With { _
.Name = "Pear", _
.Category = "Fruits" _
}, New Product() With { _
.Name = "Milk", _
.Category = "Beverages" _
}, Nw Product() With { _
.Name = "Coca Cola", _
.Category = "Beverages" _
}, New Product() With { _
.Name = "Pepsi Cola", _
.Category = "Beverages" _
}}
which seems the most useful except it complains about a type expected here "New () {..."
ive tried various things just cant figure it out... what am i missing? am i just being dumb? or isnt there and equivilent?
Cheers all