public string GetRMB(decimal moneyAmount) { string s = moneyAmount.ToString("#L#E#D#C#K#E#D#C#J#E#D#C#I#E#D#C#H#E#D#C#G#E#D#C#F#E#D#C#.0B0A");//d + "\n" + //TextBox4.Text = s; string d = System.Text.RegularExpressions.Regex.Replace( s, @"((?<=-|^)[^1-9]*)|((?'z'0)[0A-E]*((?=[1-9])|(?'-z'(?=[F-L\.]|$))))|((?'b'[F-L])(?'z'0)[0A-L]*((?=[1-9])|(?'-z'(?=[\.]|$))))", "${b}${z}"
); string res = System.Text.RegularExpressions.Regex.Replace(
d,
".", delegate(System.Text.RegularExpressions.Match m) { return "负元空零壹贰叁肆伍陆柒捌玖空空空空空空空分角拾佰仟萬億兆京垓秭穰"[m.Value[0] - '-'].ToString(); }); return res; }
测试方法:
decimal money = 5555.55M; string moneyCH = GetRMB(d); // 伍仟伍佰伍拾伍元五角伍分