简体   繁体   中英

C# Linq expression to VB.NET

I have this in C#

private Expression<Func<ObjectCollection, IEnumerable<string>>> _propertySelector;

And set as this

myComboBox.PropertySelector = collection => collection.Cast<Person>().Select(p => p.Name);

I'm using the DLL in a VB.NET project, and would like to set myComboBox.PropertySelector

The class I'm using is 'Product' which I want to use 'Product.Name' in the selector.

I thought this would work, but it's a run-time error

myComboBox.PropertySelector = myComboBox.Items.Cast(Of Product).Select(Function(p) p.Name)
myComboBox.PropertySelector = Function(x) x.Cast(Of Product).Select(Function(p) p.Name)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM