C# to VB.Net conversion issue -


when converting following line c# vb.net

expression not produce value

c#

query.tolist().foreach(ti => cat.add(ti)); 

vb.net

query.tolist().foreach(function(ti) cat.add(ti)) 

c# code :

void mainwindow_loaded(object sender, routedeventargs e) {     new designermetadata().register();      var toolbox = new toolboxcontrol();     var cat = new toolboxcategory("standard activities");     var assemblies = new list<assembly>();     assemblies.add(typeof(send).assembly);     assemblies.add(typeof(delay).assembly);     assemblies.add(typeof(receiveandsendreplyfactory).assembly);      var query = asm in assemblies                 type in asm.gettypes()                 type.ispublic &&                 !type.isnested &&                 !type.isabstract &&                 !type.containsgenericparameters &&                 (typeof(activity).isassignablefrom(type) ||                 typeof(iactivitytemplatefactory).isassignablefrom(type))                 orderby type.name                 select new toolboxitemwrapper(type);      query.tolist().foreach(ti => cat.add(ti));     toolbox.categories.add(cat);     grid.setcolumn(toolbox, 0);     grid.setrow(toolbox, 1);     layoutgrid.children.add(toolbox); } 

i want vb.net conversion. when converted code in vb.net getting error in query.tolist().foreach(function(ti) cat.add(ti)) line .error expression not produce value.

converted vb.net code

  private sub mainwindow_loaded(byval sender object, byval e routedeventargs)     dim metadata = new designermetadata()     metadata.register()      'create toolboxcontrol     dim toolbox = new toolboxcontrol()      'create collection of category items     dim cat = new toolboxcategory("standard activities")     dim assemblies = new list(of assembly)()     assemblies.add(gettype(sendandreceivereplyfactory).assembly)     assemblies.add(gettype(delay).assembly)     assemblies.add(gettype(receiveandsendreplyfactory).assembly)      dim query = _      asm in assemblies      type in asm.gettypes() _      type.ispublic andalso not type.isnested andalso not type.isabstract andalso not type.containsgenericparameters andalso (gettype(activity).isassignablefrom(type) orelse gettype(iactivitytemplatefactory).isassignablefrom(type)) _      order type.name      select new toolboxitemwrapper(type)      query.tolist().foreach(function(ti) cat.add(ti))     toolbox.categories.add(cat)     grid.setcolumn(toolbox, 0)     grid.setrow(toolbox, 1)     layoutgrid.children.add(toolbox) end sub 

change problematic line one:

query.tolist().foreach(sub(ti) cat.add(ti))  

that's necessary because there separate syntax action<t> (sub(t)) , func<t> (function(t)) in vb.net (but there not in c#).


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -