程式碼
// 將數字前面補0,補足長度為6
String snum = "5";
String pnum = snum.PadLeft(5, '0');
String fnum = String.Format("{0:00000}",Convert.ToInt16(snum));
MessageBox.Show( "原始字串 : " + snum + "\n 透過 PadLeft : " + pnum + "\n 透過 String.Format : " + fnum);
沒有留言:
張貼留言