String.Format an integer to use a thousands separator without decimal places or leading 0 for small integers

前端 未结 4 1430
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-02 13:03

Silly question, I want to format an integer so that it appears with the 1000\'s separator (,), but also without decimal places and without a leading 0.

My attempts s

4条回答
  •  不思量自难忘°
    2020-12-02 13:28

    Try this:-

    String.Format("{0:n0}",5000) // 5,000
    String.Format("{0:n0}",5) // 5
    String.Format("{0:n0}",0) // 0
    

提交回复
热议问题