Byte to Binary String C# - Display all 8 digits

前端 未结 4 953
刺人心
刺人心 2020-12-05 22:58

I want to display one byte in textbox. Now I\'m using:

Convert.ToString(MyVeryOwnByte, 2);

But when byte is has 0\'s at begining those 0\'s

4条回答
  •  难免孤独
    2020-12-05 23:14

    Convert.ToString(MyVeryOwnByte, 2).PadLeft(8, '0');
    

    This will fill the empty space to the left with '0' for a total of 8 characters in the string

提交回复
热议问题