而且不要这样做
for (int i =0;i<this.cookies.ToArray().Length;i++)
因为
this.cookies.toArray().Length
它在for循环的每一次迭代中进行评估,您每次都在制作“ this.cookies”阵列,以便您只能达到长度? :)您正在增加该方法的复杂性
题
我试图发布无限数量的赞,但根据数组中存储了多少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]);
}
}
}
解决方案 2
而且不要这样做
for (int i =0;i<this.cookies.ToArray().Length;i++)
因为
this.cookies.toArray().Length
它在for循环的每一次迭代中进行评估,您每次都在制作“ this.cookies”阵列,以便您只能达到长度? :)您正在增加该方法的复杂性
其他提示
这 真实的 问题是:
for (int j = 0; ; j++)
假设您内部没有任何其他控制语句,则产生无限循环(例如 break
, return
, goto
, throw
)
您可能打算做这样的事情:
for (int j = 0; j < this.postsIds.Length; j++)
{
...
}
for (int j = 0; ; j++)
这是一个死循环,所以我将无法达到我++