zoukankan      html  css  js  c++  java
  • [CSharp][TIP]关于数字的格式化输出

    有时要用到这个功能,但总要在MSDN中找上一陈子。
    ms-help://MS.MSDNQTR.2003FEB.2052/cpguide/html/cpconcustomnumericformatstringsoutputexample.htm


    格式 数据类型 输出
    ##### Double 123 123
    00000 Double 123 00123
    (###) ### - #### Double 1234567890 (123) 456 – 7890
    #.## Double 1.2 1.2
    0.00 Double 1.2 1.20
    00.00 Double 1.2 01.20
    #,# Double 1234567890 1,234,567,890
    #,, Double 1234567890 1235
    #,,, Double 1234567890 1
    #,##0,, Double 1234567890 1,235
    #0.##% Double 0.086 8.6%
    0.###E+0 Double 86000 8.6E+4
    0.###E+000 Double 86000 8.6E+004
    0.###E-000 Double 86000 8.6E004
    [##-##-##] Double 123456 [12-34-56]
    ##;(##) Double 1234 1234
    ##;(##) Double -1234 (1234)

    int i = 123;
    string s = string.Format("{0:00000}",i);

    output:
    = 00123
  • 相关阅读:
    Scrapy框架
    爬虫高性能相关
    存储库之MongoDB
    存储库之redis
    beautifulsoup
    pyecharts
    wxpy模块
    Gin框架
    Python的rabbitMQ
    Vue基础
  • 原文地址:https://www.cnblogs.com/xuzhong/p/438658.html
Copyright © 2011-2022 走看看