C# To VB.Net Conversion - array of class objects with initialisation

Posted by mattryan on Stack Overflow See other posts from Stack Overflow or by mattryan
Published on 2010-05-07T09:36:54Z Indexed on 2010/05/07 9:58 UTC
Read the original article Hit count: 428

Filed under:
|
|
|

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

© Stack Overflow or respective owner

Related posts about c#

Related posts about vb.net