0
我有二進制數的字符串,例如是10,我需要格式化這個字符串,它看起來像這樣:00000010C#字符串格式,添加字符字符串
我有二進制數的字符串,例如是10,我需要格式化這個字符串,它看起來像這樣:00000010C#字符串格式,添加字符字符串
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
您也可以使用此:
numberToFormat.ToString("00000000")
不,你不能做到這一點。 – DavidG 2014-10-11 11:46:05
是的,你是對的。我的錯誤,你可以格式化數字(例如int)爲字符串 – Bart 2014-10-11 11:50:51