CODEKILLER

반응형

Blazor의 인라인 C# 반복제어문입니다.

@
{
	var car = new Car[]
    {
    	new Car("Car1", 12),
        new Car("Car2", 6),
        ...
    }
}

@for (var i = 0; i < car.Length; i++)
{
    var car = car[i];
    <p>CarName: @car.Name</p>
    <p>CarAge: @car.Age</p>
}

@foreach (var car in car)
{
    <p>CarName: @car.Name</p>
    <p>CarAge: @car.Age</p>
}

@{ var i = 0; }
@while (i < car.Length)
{
    var car = car[i];
    <p>CarName: @car.Name</p>
    <p>CarAge: @car.Age</p>

    i++;
}

@{ var i = 0; }
@do
{
    var car = car[i];
    <p>CarName: @car.Name</p>
    <p>CarAge: @car.Age</p>

    i++;
} while (i < car.Length);
반응형

공유하기

facebook twitter kakaoTalk kakaostory naver band