2014-10-11 152 views

回答

3

使用String.PadLeft

string binary = "10"; 
string newBinary = binary.PadLeft(8, '0') //it returns a new string after padding chars, so you'll have to store it somewhere 
0

您也可以使用此:

numberToFormat.ToString("00000000") 
+0

不,你不能做到這一點。 – DavidG 2014-10-11 11:46:05

+0

是的,你是對的。我的錯誤,你可以格式化數字(例如int)爲字符串 – Bart 2014-10-11 11:50:51