国产探花免费观看_亚洲丰满少妇自慰呻吟_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();
    }
}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 家居| 赞皇县| 鄂托克前旗| 宿州市| 甘泉县| 丰都县| 和龙市| 含山县| 平阳县| 信阳市| 安阳市| 宜宾县| 诸城市| 天门市| 昆山市| 凤城市| 钦州市| 大洼县| 南阳市| 前郭尔| 兴安县| 屯门区| 游戏| 霸州市| 康保县| 呼玛县| 大冶市| 瓦房店市| 郴州市| 合肥市| 浙江省| 昌平区| 三台县| 玛沁县| 嘉禾县| 三亚市| 浦东新区| 宜州市| 巨野县| 玉林市| 滕州市|