反向数组的C#循环,该数组包含来自dataseries(提要)的最近7个数据
首先,大家好,谢谢你们的帮助。这是我的第一个帖子/问题。我会尽量直截了当地说反向数组的C#循环,该数组包含来自dataseries(提要)的最近7个数据,c#,arrays,loops,for-loop,C#,Arrays,Loops,For Loop,首先,大家好,谢谢你们的帮助。这是我的第一个帖子/问题。我会尽量直截了当地说 public override void Calculate(int index) { for (int i = 0; i < 7; i++) { //.. if (a_gamma[index] == TAU[index]) { a_gamma_tau_health[i] = a_gamma[index];
public override void Calculate(int index)
{
for (int i = 0; i < 7; i++)
{
//..
if (a_gamma[index] == TAU[index])
{
a_gamma_tau_health[i] = a_gamma[index];
TEST[index] = a_gamma[index];
}
//..
}
}
公共覆盖无效计算(int索引)
{
对于(int i=0;i<7;i++)
{
//..
if(a_gamma[index]==TAU[index])
{
a_gamma_tau_health[i]=a_gamma[指数];
测试[指数]=a_伽马[指数];
}
//..
}
}
//输出
a_gamma_头_健康
|71.9 | 71.9 | 71.9 | 71.9 |
我需要修复这个for*循环,因为它将在所有7个索引中输出相同的值。并建议如何获取该数组的反向,该数组将包含来自DataSeries(feed)a_gamma的最新7个数据-该系列包含double.NaN或double值(我们需要查找)。因此需要阵列中的相关双重数据进行进一步评估
//信息
public override void Calculate(int index)
{
//..
int x = 0;
int y = 0;
int z = 0;
var Display = 0.0;
var Display2 = 0.0;
var Display3 = 0.0;
var Display4 = 0.0;
for (int a = 0; a < 700; a++)
{
if (a_gamma[index - a] == TAU[index - a])
{
if ((x == 0) && (y == 0) && (z == 0))
{
Display = a_gamma[index - a];
x++;
}
else
{
if ((x != 0) && (y == 0) && (z == 0))
{
Display2 = a_gamma[index - a];
y++;
}
else
{
if ((x != 0) && (y != 0) && (z == 0))
{
Display3 = a_gamma[index - a];
z++;
}
else
{
Display4 = a_gamma[index - a];
x = 0;
y = 0;
z = 0;
}
}
}
}
}
//..
}
公共覆盖无效计算(int索引)
{
//..
int x=0;
int y=0;
int z=0;
var显示=0.0;
var Display2=0.0;
var Display3=0.0;
var Display4=0.0;
对于(int a=0;a<700;a++)
{
if(a_gamma[index-a]==TAU[index-a])
{
如果((x==0)和&(y==0)和&(z==0))
{
显示=a_伽马[索引-a];
x++;
}
其他的
{
如果((x!=0)&&(y==0)&&(z==0))
{
显示2=a_伽马[索引-a];
y++;
}
其他的
{
如果((x!=0)和&(y!=0)和&(z==0))
{
显示3=a_伽马[指数-a];
z++;
}
其他的
{
显示4=a_伽马[指数-a];
x=0;
y=0;
z=0;
}
}
}
}
}
//..
}
虽然在没有更多代码的情况下很难进行评估,但您似乎从未在循环中使用索引器(i),而是使用函数的参数(index)
也许是这样的:
public override void Calculate(int index)
{
for (int i = 0; i < 7; i++)
{
if (a_gamma[i] == TAU[index])
{
a_gamma_tau_health[i] = a_gamma[i];
TEST[i] = a_gamma[i];
}
}
}
公共覆盖无效计算(int索引)
{
对于(int i=0;i<7;i++)
{
if(a_gamma[i]==TAU[index])
{
a_gamma_tau_health[i]=a_gamma[i];
测试[i]=a_伽马[i];
}
}
}
是否应该使用中的i
而不是index
,来查找for循环中数组的索引?修复什么?预期的行为是什么?在示例中,您在哪里有任何输出?此外,您只在一个位置使用迭代变量i
:赋值,这意味着如果您的if
计算结果为true
,它将覆盖数组a_gamma\u tau\u health
中的所有值,请写清楚的问题,并避免像str8forward那样写得不好。使用这样的作品显然缺乏努力,在专业网站上是不可接受的。这显然是一个错误,但出于良好的意图。我想在写作中有点个性吧。无论如何,谢谢你关注这个令人惊叹的网站。我不知道会发生什么。这显然是尖锐和专业的。@unhylysheep-你在做什么。也许这就是为什么我在所有7中得到相同的值。我该如何解决或修复这个问题?如果我的循环将数据系列7的值推过并找到它需要的值,那么它应该会起作用。但是[index]会处理这个问题,我需要[I]在(if)为真时输入它将找到的值。我只需要最后7个值。测试[索引]在所有数据正确的情况下亮起,但a_gamma_tau_health的最后一个值重复了7次。