[C#]&、|和^

参考链接:

http://www.runoob.com/csharp/csharp-operators.html

表:

简单来说,就是:

&:全1为1,否则为0

|:有1为1,否则为0

^:不同为1,否则为0

测试:

 1 using UnityEngine;
 2 
 3 public class NewBehaviourScript : MonoBehaviour
 4 {
 5     void Start()
 6     {
 7         print(2 & 1);//0
 8         print(2 | 1);//3
 9         print(2 ^ 1);//3
10     }
11 }

猜你喜欢

转载自www.cnblogs.com/lyh916/p/10739328.html
今日推荐