如何将此行转换为vb.net

时间:2021-05-07 21:09:57

from the free dinner book for asp.net MVC

来自asp.net MVC的免费晚餐书

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Edit(int id, FormCollection formValues) {
    Dinner dinner = dinnerRepository.GetDinner(id);
    UpdateModel(dinner);
    dinnerRepository.Save();
    return RedirectToAction("Details", new { id = dinner.DinnerID });
}

how to convert this line into vb.net?

如何将此行转换为vb.net?

return RedirectToAction("Details", new { id = dinner.DinnerID });

more the new { id = dinner.DinnerID } part

更多新的{id = dinner.DinnerID}部分

thanks

4 个解决方案

#1


Try this

Return RedirectToAction("Details", New With { .id = dinner.DinnerID})

In VB the anonymous type declaration syntax, as well as normal object initializers, needs a "." prefix on all of the property names. This is consistent with other VB features such as the With context.

在VB中,匿名类型声明语法以及普通对象初始化器需要“。”。所有属性名称的前缀。这与其他VB功能(如With上下文)一致。

#2


That is using an anonymous type, so it will look like this:

那是使用匿名类型,所以它看起来像这样:

Return RedirectToAction("Details", New With { .id = dinner.DinnerID })

#3


This should work:

这应该工作:

Return RedirectToAction("Details", New With { .id = dinner.DinnerID })

#4


New With {.id = dinner.DinnerID}

#1


Try this

Return RedirectToAction("Details", New With { .id = dinner.DinnerID})

In VB the anonymous type declaration syntax, as well as normal object initializers, needs a "." prefix on all of the property names. This is consistent with other VB features such as the With context.

在VB中,匿名类型声明语法以及普通对象初始化器需要“。”。所有属性名称的前缀。这与其他VB功能(如With上下文)一致。

#2


That is using an anonymous type, so it will look like this:

那是使用匿名类型,所以它看起来像这样:

Return RedirectToAction("Details", New With { .id = dinner.DinnerID })

#3


This should work:

这应该工作:

Return RedirectToAction("Details", New With { .id = dinner.DinnerID })

#4


New With {.id = dinner.DinnerID}