我想在每次重复foreach
循环
@foreach (var item in Model)
{
Random r = new Random();
int s = r.Next(0, 5);
<span>@(s)</span>
}
但我得到相同的值而不是随机值。
答案 0 :(得分:1)
Random r = new Random();
@foreach (var item in Model)
{
int s = r.Next(0, 5);
<span>@(s)</span>
}