Razor C# code to VB

847 views Asked by At

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

2

There are 2 answers

1
Cody Gray - on strike On BEST ANSWER

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)
0
Sujay Ghosh On