开发者

Why doesn't this (translated) VB.NET code work?

开发者 https://www.devze.com 2022-12-25 01:37 出处:网络
I had a piece of C# code converted, but the translated code isn\'t valid... Can somebody help out? C# <table>

I had a piece of C# code converted, but the translated code isn't valid... Can somebody help out?

C#

<table>
  <% Html.Repeater<Hobby>("Hobbies", "row", "row-alt", (hobby, css) => { %>
  <tr class="<%= css %>">
    <td><%= hobby.Title%></td>
  </tr>
  <% }); %>
</table>

VB

<% Html.Repeater(of Hobby)(Model.Hobbies, "row", "row-alt", Function(hobby, css) Do %>   
  <tr class="<%= css %>">
   开发者_JS百科 <td><%= hobby.Title%></td>
  </tr>      
<%  End Function)%>


It looks like you are attempting to use a statement lambda in VB.net. These are not supported in VB.net until Visual Studio 2010. The previous version of the language only supports expression lambdas which don't work in this scenario

If you are using 2010 you need to remove the Do immediately following the Function header. It's not necessary and will instead force the lambda to be an expression lambda instead of a statement lambda.

0

精彩评论

暂无评论...
验证码 换一张
取 消