如何使用Razor语法输出一个每行有2项的表

如何使用Razor语法输出一个每行有2项的表,razor,Razor,我不确定我是否理解Razor语法,但似乎无法使用以下代码生成表。编译器似乎总是期望整洁地关闭标记 <div> @foreach (var image in images) { if (@currentCount == 0) { <div class="row"> } <div class="column&quo

我不确定我是否理解Razor语法,但似乎无法使用以下代码生成表。编译器似乎总是期望整洁地关闭标记

<div>


    @foreach (var image in images)
    {
        if (@currentCount == 0)
        {
            <div class="row">

        }

                <div class="column">
                    <img src="images/@image.Thumbnail" width="400">
                    @image.Title
                </div>

        @if (@currentCount == 2)
        {
            </div>
            @currentCount = 0;
        }
        else
        {
            @currentCount += 1;
        }


    }
    @if (currentCount > 0)
    {
         </div>
    }

</div>

@code {
    private Image[] images;
    private string rootDir = "images/";

    private int currentCount = 0;

    protected override async Task OnInitializedAsync()
    {
        images = await Http.GetFromJsonAsync<Image[]>("sample-data/images.json");

    }
}

@foreach(图像中的var图像)
{
如果(@currentCount==0)
{
}
@图片。标题
@如果(@currentCount==2)
{
@currentCount=0;
}
其他的
{
@currentCount+=1;
}
}
@如果(当前计数>0)
{
}
@代码{
私有图像[]图像;
私有字符串rootDir=“images/”;
私有int currentCount=0;
受保护的重写异步任务OnInitializedAsync()
{
images=wait Http.GetFromJsonAsync(“sample data/images.json”);
}
}