首页 > 代码库 > C#:小写金额转换为大写
C#:小写金额转换为大写
#region 小写金额转换为大写 public static string CurrToChnNum(double Currnum) { string sResult = ""; if (Math.Abs(Currnum) < 1e-20) return "零圆整"; if (Currnum < 1e-20) sResult = "负"; sResult = sResult + StringToChnNum(Math.Abs(Math.Round(Currnum, 2)).ToString()); return sResult; } private static string FourNumToChnNum(string Str, string ChnNum, ref Boolean Pre) { string[] Digits = {"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"}; int i, j, Len; string sResult = ""; Len = Str.Length; for (i = 0; i < Len; i++) { j = Str[i] - 48; if (0 == j) Pre = true; else { if (Pre) sResult = sResult + "零"; sResult = sResult + Digits[j] + ChnNum.Substring(Len - i - 1, 1); Pre = false; } } return sResult.Trim(); } //将格式化好的小写串转换为大写串 private static string StringToChnNum(string str) { const string ChnNum1 = "圆万亿兆"; int i, Len, Len1, Level, Start; string s1; string s; Boolean Pre; string sResult = ""; Len = str.IndexOf(‘.‘); Level = (Len + 3) / 4; Len1 = Len % 4; if (0 == Len1) Len1 = 4; Start = 0; for (i = 1; i <= Level; i++) { Pre = false; s = str.Substring(Start, Len1); s1 = FourNumToChnNum(s, " 拾佰仟", ref Pre); if (s1.Length > 0) sResult = sResult + s1 + ChnNum1.Substring(Level - i, 1); Start = Start + Len1; Len1 = 4; } Pre = false; s1 = FourNumToChnNum(str.Substring(Len + 1, Math.Min(2, str.Length - Len - 1)), "分角", ref Pre); //s1 = ""; if (s1.Length == 0) s1 = "整"; sResult = sResult + s1; return sResult; } #endregion
C#:小写金额转换为大写
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。