views:

54

answers:

1

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 %>">
    <td><%= hobby.Title%></td>
  </tr>      
<%  End Function)%>
+3  A: 

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.

JaredPar
Thanks for the insight, but what does this article say then? http://blogs.msdn.com/codeanalysis/archive/2007/09/21/new-for-visual-studio-2008-support-for-anonymous-methods-and-lambda-expressions.aspx
Ropstah