How to use generic syntax inside a Razor view file?

后端 未结 5 1626
遥遥无期
遥遥无期 2021-02-04 23:26

I was trying to use the following statement:

@Html.Test().Nand()

However, Razor is choking at the < before the ISQL.

Any

5条回答
  •  孤独总比滥情好
    2021-02-04 23:40

    I had a strange case when I had several assignments inside of one @{ ... } bock.

    @{
        // ... other assignments (without error)
        List stringList = new List()  // ERROR MESSAGE HERE
    }
    

    What ever I did, there were always errors, like this:

    Using the generic type 'List' requires one type arguments

    The solution: I put the assignment line to a second @{ ... } bock.

    @{
        // ... other assignments
    }
    @{
        List stringList = new List()  // WORKS
    }
    

提交回复
热议问题