<分区>
在 C# 中可以使用没有值的 if 内联条件,换句话说返回 void
?
public void FuncReturningVoid ()
{
return;
}
public void AnotherFuncReturningVoid()
{
return;
}
public void Test ()
{
int a = 1;
int b = 2;
// I whish I could to do this:
a == b ? FuncReturningVoid() : AnotherFuncReturningVoid();
//would be the same...
if (a == b)
{
FuncReturningVoid();
}
else
{
AnotherFuncReturningVoid();
}
}