我想了解这段代码:
class Worker
{
public bool DoThisJob(string job, int numberOfShifts)
{
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;
}
}
Run Code Online (Sandbox Code Playgroud)
如果这个if语句有多行代码(包括for循环和两个returns),为什么它没有花括号?