- A+
所属分类:.NET技术
/// <summary> /// 字符串去除千分位,可以指定精度,默认为两位小数,若失败字符串为0 /// </summary> /// <param name="This"></param> /// <param name="accuracy"></param> /// <returns></returns> public static String ParseThousands(this String This, int accuracy = 2) { if (String.IsNullOrEmpty(This)) return This; try { This = double.Parse(This, NumberStyles.AllowThousands | NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign).ToString(String.Format("F{0}", accuracy)); } catch (Exception) { This = 0.ToString(String.Format("F{0}", accuracy)); } return This; }