Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Loops 在razor页面Blazor上的@code块内的循环上获取蠕动错误_Loops_Razor_Blazor - Fatal编程技术网

Loops 在razor页面Blazor上的@code块内的循环上获取蠕动错误

Loops 在razor页面Blazor上的@code块内的循环上获取蠕动错误,loops,razor,blazor,Loops,Razor,Blazor,在razor页面Blazor上的@code块内的循环上获取蠕动错误 @code{ 字符串Vh=“0 600 200”; int i=0;List dis2=new List(); 字符串[]dis={“400”、“650”、“660”、“700”、“750”、“800”、“850”、“900”、“950”、“950”、“950”}; 专用静态系统。计时器。计时器位于; foreach(varv在dis中){} 专用静态系统定时器定时器定时器; } 您已经在类主体中声明了一个foreach循环。

在razor页面Blazor上的@code块内的循环上获取蠕动错误

@code{
字符串Vh=“0 600 200”;
int i=0;List dis2=new List();
字符串[]dis={“400”、“650”、“660”、“700”、“750”、“800”、“850”、“900”、“950”、“950”、“950”};
专用静态系统。计时器。计时器位于;
foreach(varv在dis中){}
专用静态系统定时器定时器定时器;
}

您已经在类主体中声明了一个foreach循环。您需要将它放在一个方法中或在@code部分上面使用它,然后它将需要一个@foreach

@foreach (var v in dis)
{
}
@code
{
    string Vh = "0 0 600 200";
    int i = 0;
    List<string> dis2 = new List<string>();
    string[] dis = new[] { "400", "650", "660", "700", "750", "800", "850", "900", "950", "950", "950" };
    private static System.Timers.Timer aT;
    private static System.Timers.Timer aTimer;
} 
@foreach(dis中的变量v)
{
}
@代码
{
字符串Vh=“0 600 200”;
int i=0;
List dis2=新列表();
字符串[]dis=new[]{“400”、“650”、“660”、“700”、“750”、“800”、“850”、“900”、“950”、“950”、“950”};
专用静态系统。计时器。计时器位于;
专用静态系统定时器定时器定时器;
} 

@code{string Vh=“0 0 600 200”;int i=0;List dis2=new List();string[]dis={“400”、“650”、“660”、“700”、“750”、“800”、“850”、“900”、“950”、“950”、“950”};私有静态系统.Timers.Timer aT;foreach(dis中的var v){}私有静态系统.Timers.Timer aTimer;}代码块是类级容器。您的循环需要位于方法内部。
@foreach (var v in dis)
{
}
@code
{
    string Vh = "0 0 600 200";
    int i = 0;
    List<string> dis2 = new List<string>();
    string[] dis = new[] { "400", "650", "660", "700", "750", "800", "850", "900", "950", "950", "950" };
    private static System.Timers.Timer aT;
    private static System.Timers.Timer aTimer;
}