EKsumic's Blog

let today = new Beginning();

Click the left button to use the catalog.

OR

C#中if-else的简写

号后面是判断之后的输出语句,

的左边是判断为真的时候的输出

      右边是判断为否的时候的输出

 

举个例子:

m_GroundCheckDistance = m_Rigidbody.velocity.y < 0 ? m_OrigGroundCheckDistance : 0.01f;

 

相当于:

if(m_Rigidbody.velocity.y < 0)

{

      m_GroundCheckDistance = m_OrigGroundCheckDistance;

}

else

{

      m_GroundCheckDistance =0.01f;

}

 

应用场景:

当只有1个需要判定的值的时候。

 

This article was last edited at 2020-04-08 01:34:21

* *