How to use generic syntax inside a Razor view file?
Solution 1:
To use generic methods you need to escape the expression
@(Html.Test<ISQL>().Nand())
Solution 2:
I just found this question when I was looking for this "same error" when upgrading mvc.
I had :
Does not work:
@{
ViewBag.Title = "Something " + @Model.Title;
var something = (IEnumerable<SelectListItem>)ViewBag.Options;
}
Apparently, the syntax went stricter, and as you are inside a @{} block, you should not add @ before Model.Title on the example. But the error on the code editor was pointing to the generic and it was getting me crazy.
It works fine if there is no <> inside the code, but just removing the @ from Model.Title fix the issue.
Works:
@{
ViewBag.Title = "Something " + Model.Title;
var something = (IEnumerable<SelectListItem>)ViewBag.Options;
}
Hope this helps to anyone