无法访问的代码在哪里?

发布于 2024-07-24 15:50:58 字数 548 浏览 4 评论 0原文

int x;
int iHateDataRows = dt.Rows.Count + 2;
System.Data.DataRow[] dra = new System.Data.DataRow[1000];

for(x = 0; x < iHateDataRows; ++x)

所以,这显然是一个循环,但是我的问题是 ++x 告诉我它无法访问。 我不知道这是否只是我的IDE发疯了还是什么(我使用SharpDevelop,主要是因为VS2008太笨重并且没有我喜欢的简洁的小功能。)

我希望我提供了足够的信息供人们猜测问题。 我一直盯着这个东西,改变了变量。 一切,都不会动摇。

编辑:

这是在 for 循环之后:

if(dra[x].ItemArray[2].ToString() == "0")
{
    return x.ToString();
}
else
{
    return "Fail";
}

我当然希望这段代码是正确的,因为我从未测试过它。

int x;
int iHateDataRows = dt.Rows.Count + 2;
System.Data.DataRow[] dra = new System.Data.DataRow[1000];

for(x = 0; x < iHateDataRows; ++x)

So, this is obviously a loop but, my problem is that the ++x tells me that it is unreachable. I don't know if this is just my IDE going crazy or something (I use SharpDevelop, mostly because VS2008 is too clunky and doesn't have neat little features that I like.)

I hope I provided enough info for someone to guess at the problem. I have stared at this thing, changed the variables. Everything, it won't budge.

EDIT:

This is after the for loop:

if(dra[x].ItemArray[2].ToString() == "0")
{
    return x.ToString();
}
else
{
    return "Fail";
}

I sure hope this code is correct as I never got to test it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不知所踪 2024-07-31 15:50:58

在进入下一次迭代之前,您总是从循环中返回。 也就是说,“if”语句的两部分都返回。 你永远不会回到循环的顶部。

You are always returning from the loop before it goes to the next iteration. That is, both halves of the "if" statement return. You never go back to the top of the loop.

感性 2024-07-31 15:50:58

您可能在循环内有一个 breakreturn(或者,天堂不允许,goto)。

You probably have a break or return (or, heaven forbid, goto) inside the loop.

窝囊感情。 2024-07-31 15:50:58

由于循环中的一个或另一个“if”子句将被执行,因此保证会发生返回,并且循环将永远不会运行第二次迭代; 因此,增量永远不会发生。

Since either one or the other "if" clause in the loop will be executed, a return is guaranteed to occur, and the loop will never run a second iteration; thus, the increment will never take place.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文