Search code examples
vb.netrazorc#-to-vb.netnamed-parameters

Razor C# code to VB


I trying to convert this C# code VB.Net. its giving syntax error.

C#

@{
var grid = new WebGrid(source: data, 
                           defaultSort: "name",  
                           rowsPerPage: 30) 
}

VB.Net

@Code
Dim grid as new WebGrid(source: data, 
                           defaultSort: "name",  
                           rowsPerPage: 30); 
End Code

What is the correct say to convert this?

-SR


Solution

  • VB.NET has a different syntax for named parameters than does C#. (They were around in VB for a long time before they ever made their way into C#.)

    You can rewrite the code like this:

    Dim grid As New WebGrid(source := data, defaultSort := "name", rowsPerPage := 30)