日期:2014-05-18 浏览次数:20792 次
//NumberGroupSeparator : 获取或设置在数值中对小数点左边数字进行分组的字符串。 //NumberDecimalSeparator : 获取或设置在数值中用作小数点分隔符的字符串。 String num1 = "123,456,789"; String num2 = "123|456|789"; String num3 = "123.456.789"; String num4 = "123,456.789"; String num5 = "123.456,789"; System.Globalization.NumberFormatInfo nfi = new System.Globalization.NumberFormatInfo(); nfi.NumberGroupSeparator = ","; int x1 = int.Parse(num1, System.Globalization.NumberStyles.AllowThousands, nfi); nfi.NumberGroupSeparator = "|"; int x2 = int.Parse(num2, System.Globalization.NumberStyles.AllowThousands, nfi); nfi.NumberGroupSeparator = "."; int x3 = int.Parse(num3, System.Globalization.NumberStyles.AllowThousands, nfi); nfi.NumberGroupSeparator = ","; nfi.NumberDecimalSeparator = "."; Decimal x4 = Decimal.Parse(num4,nfi); nfi.NumberGroupSeparator = "."; nfi.NumberDecimalSeparator = ","; Decimal x5 = Decimal.Parse(num5, nfi); Response.Write("<li>" + x1); Response.Write("<li>" + x2); Response.Write("<li>" + x3); Response.Write("<li>" + x4); Response.Write("<li>" + x5);