/// <summary> /// 转换四位数字 /// </summary> private static string To4Digit(string str) { string result = string.Empty; try { string str1 = str.Substring(0, 1); string str2 = str.Substring(1, 1); string str3 = str.Substring(2, 1); string str4 = str.Substring(3, 1); result += Convert.To1Digit(str1) + "仟"; result += Convert.To1Digit(str2) + "佰"; result += Convert.To1Digit(str3) + "拾"; result += Convert.To1Digit(str4); result = result.Replace("零仟", "零"); result = result.Replace("零佰", "零"); result = result.Replace("零拾", "零"); result = result.Replace("零零", "零"); result = result.Replace("零零", "零"); result = result.Replace("零零", "零"); } catch (Exception ex) { Debug.WriteLine("Convert.To4Digit(string) :: " + ex.Message); throw ex; } return(result); }
/// <summary> /// 转换数字(小数部分) /// </summary> private static string ToDecimalStr(string str) { string result = string.Empty; try { int strlen = str.Length; if (strlen == 1) { result = Convert.To1Digit(str) + "角"; } else { string tmpstr = str.Substring(0, 1); result = Convert.To1Digit(tmpstr) + "角"; tmpstr = str.Substring(1, 1); result += Convert.To1Digit(tmpstr) + "分"; result = result.Replace("零分", ""); result = result.Replace("零角", ""); } } catch (Exception ex) { Debug.WriteLine("Convert.ToDecimalStr(string) :: " + ex.Message); throw ex; } return(result); }