Converting string to int without losing the zero in the beginning

后端 未结 10 569
Happy的楠姐
Happy的楠姐 2021-01-02 03:49

I tried int.parse, and convert class to convert a string to int.

While I\'m converting. I\'m losing the 0 in the beginning which i don\'t want.

10条回答
  •  旧巷少年郎
    2021-01-02 04:15

    If you want to do something like always print your number with 5 places, it goes like

    myNumber.ToString().PadLeft(5, '0');
    

提交回复
热议问题