编程语言
首页 > 编程语言> > [C#]byte

[C#]byte

作者:互联网

参考链接:

https://docs.microsoft.com/zh-cn/previous-versions/5bdb6693(v=vs.110)?redirectedfrom=MSDN

 

定义:

 

测试:

 1 using System;
 2 using UnityEngine;
 3 
 4 public class TestByte : MonoBehaviour
 5 {
 6     void Start()
 7     {
 8         //Convert.ToString(xxx, 2),转换为二进制字符串
 9         byte by;
10         by = 2;
11         print(Convert.ToString(by, 2));
12         by = 255;
13         print(Convert.ToString(by, 2));
14 
15         //0000 0010  |
16         //0000 0011  =
17         //0000 0011
18         by = 2 | 3;
19         print(Convert.ToString(by, 2));
20 
21         int a = 258;
22         print(Convert.ToString(a, 2));
23         print(Convert.ToString((byte)(a >> 8), 2));
24         print(Convert.ToString((byte)(a), 2));
25     }
26 }

 

输出:

 

标签:Convert,0000,0011,C#,ToString,print,byte
来源: https://www.cnblogs.com/lyh916/p/15866280.html