【发布时间】:2016-02-20 08:02:52
【问题描述】:
我有以下 while 语句 -
while ((!testString.Contains("hello")) && (NewCount != OldCount) && (attemptCount < 100))
{
//do stuff (steps out too early)
}
即使所有条件都没有满足,这也是退出语句。
我试图减少它 -
while (!testString.Contains("hello"))
{
// this works and steps out when it should
}
例如,当出现hello 时,它就会退出。我还尝试将其更改为 OR 语句,该语句将问题反转为永远不会退出该语句。
添加&& (NewCount != OldCount) && (attemptCount < 100)) 条件导致此行为我该如何解决?
【问题讨论】:
-
NewCount、OldCount和attemptCount的值是多少? -
我认为您需要为此提供更多上下文。
标签: c# while-loop conditional-statements