Use switch case in MVC view
It's simple, you use your code same as this, It's works fine.
@for (var i = 0; i < 4; i++)
{
<div>
@switch (i)
{
case 0:
<div>Custom Value 1</div>
break;
case 1:
<span>Custom Value 2</span>
break;
}
</div>
}
Switch (condition)
{
Case value or result :
Statement
Break;
Default:
}
This should work.
@for (var i = 0; i < 4; i++)
{
<div>
@switch (i)
{
case 0:
<div>Custom Value 1</div>
break;
case 1:
<span>Custom Value 2</span>
break;
}
</div>
}