开发者

double alignment using string.format

开发者 https://www.devze.com 2022-12-13 06:19 出处:网络
I was trying to align doubles using string.format and display them on a tooltip. I used: string.Format(\"{0,15:N2}\", number);

I was trying to align doubles using string.format and display them on a tooltip.

I used: string.Format("{0,15:N2}", number);

but the results come out as:

   1234.56
    00.00

It seems some of the numbers are narrower t开发者_如何学Gohan the space. Does anyone know how to solve this problem?

Thanks!


Use a fixed-width font such as Courier New or Consolas if you want all the individual digits to line up.

0

精彩评论

暂无评论...
验证码 换一张
取 消