国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

C#小Tip:數字格式化顯示

2024-07-21 02:26:36
字體:
來源:轉載
供稿:網友

using system;
class program
{

    static void main()
    {
        decimal thedecnumber = 12345.678m; //the "m" creates a literal of type decimal from a double
        //using the tostring method
        //the number in the format string is the precision specifier
        console.writeline("no formatting: " + thedecnumber.tostring());
        console.writeline("currency formatting: " + thedecnumber.tostring("c"));
        console.writeline("exponential formatting: " + thedecnumber.tostring("e"));
        console.writeline("fixed-point formatting: " + thedecnumber.tostring("f2"));
        console.writeline("general formatting: " + thedecnumber.tostring("g"));
        console.writeline("number formatting to 2 decimal places: " + thedecnumber.tostring("n2"));
        console.writeline("number formatting to 3 decimal places: " + thedecnumber.tostring("n3"));
        console.writeline("number formatting to 4 decimal places: " + thedecnumber.tostring("n4"));
        console.writeline("percent formatting: " + thedecnumber.tostring("p0"));

        int theintnumber = 123456;
        console.writeline("hexidecimal formatting (for integers): {0} = {1}", theintnumber, theintnumber.tostring("x"));

        double thedblnumber = 1234567890;
        console.writeline("custom formatting: {0} to us telephone {1}", thedblnumber, thedblnumber.tostring("(###) ### - ####"));

        //keep console open if not run through command prompt
        console.write("/npress enter to continue");
        console.readline();
    }
}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 京山县| 专栏| 博爱县| 朝阳县| 濮阳县| 万源市| 东乡族自治县| 龙泉市| 平陆县| 西和县| 宁乡县| 邹平县| 乌海市| 湘阴县| 罗平县| 扶风县| 鹿泉市| 太谷县| 东丰县| 体育| 琼海市| 景泰县| 白河县| 工布江达县| 久治县| 仙居县| 永顺县| 齐河县| 荥阳市| 栾城县| 互助| 勃利县| 梅州市| 铜川市| 斗六市| 岳普湖县| 汾西县| 旺苍县| 文安县| 靖安县| 克什克腾旗|