有没有更简洁的写作方式?
articleCount += 1;
if (articleCount > 4)
{
// Reset counter to 1
articleCount = 1;
}
Run Code Online (Sandbox Code Playgroud)
对于那些喜欢数学难题不可读代码的人,以下内容也可以:
articleCount = (articleCount % 4) + 1;
Run Code Online (Sandbox Code Playgroud)