编程和阅读如何预订的新手。问题是关于循环的。我有以下代码:
public bool DoThisJob(string job, int numShift) {
if (!string.IsNullOrEmpty(currentJob))
return false;
for (int i = 0; i < jobsICanDo.Length; i++) {
if (jobsICanDo[i] == job) {
currentJob = job;
this.shiftsToWork = numberOfShifts;
shiftsWorked = 0;
return true;
}
return false;
如果 currentJob 字符串不为空则返回 false 还是返回 true?没有其他声明,所以如果它是真的,我们怎么知道该怎么做?
接下来运行一个for循环,然后for循环再次运行,因为它返回false或true?最后运行一个不言自明的 if 语句。