Bru*_*ali 4 c# methods if-statement inline void
在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();
}
}
Run Code Online (Sandbox Code Playgroud)