c#及js实现将金融变成3位一逗号

1、c#用string.format

ToString("#,###.00")

2、js方法 转自http://www.cnblogs.com/cssfirefly/p/3582027.html

(1)

 var   num_s = "1232134456.546 ";
    alert(parseFloat(num_s).toLocaleString());
(2)
 function format_number(nStr ){
        nStr += '';  
        x = nStr.split('.');  
        x1 = x[0];  
        x2 = x.length > 1 ? '.' + x[1] : '';  
        var rgx = /(d+)(d{3})/;  
        while (rgx.test(x1)) {  
            x1 = x1.replace(rgx, '$1' + ',' + '$2');  
        }  
        return x1 + x2;  
    }

    var a="53669988.000";
    alert(format_number(a));
    alert(format_number("wahh"));
    alert(format_number(0));
    alert(format_number(6698.0023));
原文地址:https://www.cnblogs.com/taoshengyujiu/p/5779409.html