简体   繁体   中英

Strange Razor C# to VB Syntax

I am trying to convert the following code so that it uses vbhtml instead of cshtml.

01  @{
02      Html.MobSyncfusion().Header("sfheader")
03          .Position(MobPosition.Fixed)
04          .RenderMode(RenderMode.IOS)
05          .Title(@ViewData["CurrentProduct"].ToString())
06          .IOS(ios =>
07          {
08              ios.RightButton(button =>
09              {
10                  button.ShowButton(true).Caption("Products");
11              });
12          }).Render();
13  }

So far I have managed to convert most of this, however the IOS section is proving difficult, I have so far been unable to find any resource on the internet that even shows the C# syntax used here.

Also the developerfusion tool is of no help, it just spat out some nonsense code I have never seen this syntax before in C#

My conversion so far:

01    @Code
02        With Html.MobSyncfusion().Header("sfheader")
03            .Position(MobPosition.Fixed)
04            .RenderMode(RenderMode.IOS)
05            .Title(ViewData("CurrentProduct").ToString)
06            .IOS()
07                 
08            .Render()
09        End With
10  End Code

This is a master layout view page, Also I am very new to MVC, so any help converting this would be great.

Thanks.

Those are lambda expressions. They look very different in VB. Here's a set of single- and multi-line lambda expressions in C#, and then the equivalent set in VB:

C#:

var list = new List<string>();

list.Any(x => x.Length > 5);

list.Any(x => 
{
    return x.Length > 5;
});

list.ForEach(x => Debug.Print(x));

list.ForEach(x => 
{
    Debug.Print(x);
});

VB:

Dim list = New List(Of String)

list.Any(Function(x) x.Length > 5)

list.Any(Function(x)
             Return x.Length > 5
         End Function)

list.ForEach(Sub(x) Debug.Print(x))

list.ForEach(Sub(x)
                 Debug.Print(x)
             End Sub)

For more details, have a look at these links:

Lambda Expressions (Visual Basic)

How to: Create a Lambda Expression (Visual Basic)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM