下面的类中的逻辑if-else
语句尽可能短,c# 允许,或者这个语句可以更短吗?
?:
MSDN 上的逻辑结构在某些情况下是捷径,但不是以下情况?
class Stats
{
public int Total = 0;
public int Missed = 0;
public int Correct = 0;
public int Accuracy = 0;
void Update(Boolean correctKey)
{
//correctKey ? Correct++ : Missed++; //incorrect syntax for this situation as the ? operator is used to set a value
if (correctKey==true) Correct++; else Missed++; //shortest c# syntax?
}
}