close
Convert.ToString(數值, 基底)
example 1.
Convert.ToString(5, 2)
結果: 101
example 2. 補齊4位數
Convert.ToString(5, 2).PadLeft(4,'0')
結果: 0101
1: int action = 1; // 0:display, 1:write, 2:erase
2: int block = 1; // 0~15, block number
3: string para = Convert.ToString(action, 2).PadLeft(4, '0') + Convert.ToString(block, 2).PadLeft(4, '0');
4: int data = Convert.ToInt32(para, 2);
5: byte b = byte.Parse(data.ToString());
結果:
para = ‘00010001’
data = 17 (int)
b = 17 (byte)
全站熱搜
留言列表