我想在文本框中顯示一個字節。 現在我使用:字節到二進制字符串C# - 顯示全部8個數字
Convert.ToString(MyVeryOwnByte, 2);
但是,當一個字節是具有0的在begining的被cuted那些0。 示例:
MyVeryOwnByte = 00001110 // Texbox shows -> 1110
MyVeryOwnByte = 01010101 // Texbox shows -> 1010101
MyVeryOwnByte = 00000000 // Texbox shows -> <Empty>
MyVeryOwnByte = 00000001 // Texbox shows -> 1
我想顯示所有8位數字。
請參閱: http://stackoverflow.com/questions/1644609/c-problem-with-byte和具體http://stackoverflow.com/questions/1644609/c-problem-with-byte/1644666#1644666 – 2011-01-28 14:39:26
作爲在這個代碼問題已經[被另一個用戶誤解了](http://stackoverflow.com/questions/22894695/preceding-0s-in-integer-value),應該指出`MyVeryOwnByte`實際上不是`byte` (如果這是實際使用的C#代碼)文字(例如`01010101`)是* decimal *數字(碰巧只包含零和1);構成這些數字的字節的實際位看起來有點不同。 – 2014-04-06 14:10:09
@ O.R.Mapper它只是「僞代碼」。 – Hooch 2014-04-06 16:01:46