Question C# to VB.NET conversion

prorata.net

New member
Joined
Jul 6, 2011
Messages
1
Programming Experience
Beginner
Hi All,
I am converting a C# Web Application to VB.NET. The problem occurs with the line of code in RED colour. I am unable to find a VB.NET equivalent of this line.


ArrayList arrSymbologies = new ArrayList();

// get all public static properties
PropertyInfo[] propertyInfos;
propertyInfos = typeof(BarCodeReadType).GetProperties(BindingFlags.Public |
BindingFlags.Static);
// sort properties by name
Array.Sort(
propertyInfos, delegate(PropertyInfo propertyInfo1, PropertyInfo propertyInfo2)
{ return propertyInfo1.Name.CompareTo(propertyInfo2.Name); }
);

​I tried different online (free) C# to VB.NET converters, they convert is as follows, but the Visual studio give errors (BC30201: Expression expected. ; BC32017: Comma, ')', or a valid expression continuation expected.)

Array.Sort(propertyInfos, Function(propertyInfo1 As PropertyInfo, propertyInfo2 As PropertyInfo) propertyInfo1.Name.CompareTo(propertyInfo2.Name))

Please help in this regard.
Thanks in Advamce
Babar
 
In place of the delegate use AddressOf statement pointing to your comparison function. This is the Comparison(Of T) delegate parameter of Sort method.
You're using a really old IDE, in the newer VB versions inline methods (lambda expressions) like that is allowed.
 
Back
Top