Add comma to numbers every three digits using C#

后端 未结 6 1804
醉话见心
醉话见心 2021-01-02 11:02

I want to add comma to decimal numbers every 3 digits using c#.
I wrote this code :

double a = 0; 
a = 1.5;
Interaction.MsgBox(string.Format(\"{0:#,###0}         


        
6条回答
  •  粉色の甜心
    2021-01-02 11:40

    Its doing it right. #,##0 means write at least one digit and zero decimals and space digit groups with comas. Therefore it rounds 1.5 to 2 as it cant write decimals. Try #,##0.00 instead. You'll get 1.50

提交回复
热议问题