use*_*751 0 .net c# for-loop control-structure unreachable-code
我试图发布无限数量的喜欢,但根据数组中存储的cookie数量来循环cookie和代理.显然,i ++是无法访问的代码.这是什么原因?
public void PostLikes()
{
PostLike postLike = new PostLike();
for (int i =0;i<this.cookies.ToArray().Length;i++)
{
for (int j = 0; ; j++)
{
postLike.PostLike(this.cookies[i], this.importedProxies[i], this.proxyUsernameTextbox, this.proxyPasswordTextbox, this.postsIds[j]);
}
}
}
Run Code Online (Sandbox Code Playgroud)
在真正的问题是:
for (int j = 0; ; j++)
Run Code Online (Sandbox Code Playgroud)
产生无限循环,假设你没有内部的任何其他控制语句(如break,return,goto,throw)
你可能想做这样的事情:
for (int j = 0; j < this.postsIds.Length; j++)
{
...
}
Run Code Online (Sandbox Code Playgroud)