[记录]将小写金额转换为大写金额

时间:2021-06-16 09:11:50
void MainFormLoad(object sender, EventArgs e)
{
this.Text = GetToZHString(1234325.78f);
}
public static string GetToZHString(float value)
{
string str = "";
string[] s = { "", "", "", "", "", "", "", "", "", "", "亿", "", "", "" };
char[] c = { '', '', '', '', '', '', '', '', '', '' };
bool b = value < 0;
if (b)
{
value = 0 - value;str = "";
}
string temp = value.ToString("#0.00").Replace(".", string.Empty);

int count = temp.Length - 1;
for (int i = 0; i <= count; i++)
{
str += c[int.Parse(temp[i].ToString())] + s[count - i];
}
return str;
}