这个函数只支持到千万,如想要更大请改一下这个地方 string y="元拾佰仟萬拾佰仟"; ,有不对的地方请更正。
private static string yget(int xiaoxie)
{
string s="";
switch(xiaoxie)
{
case 0:
s="零";
break;
case 1:
s="壹";
break;
case 2:
s="貳";
break;
case 3:
s="參";
break;
case 4:
s="肆";
break;
case 5:
s="伍";
break;
case 6:
s="陸";
break;
case 7:
s="柒";
break;
case 8:
s="捌";
break;
case 9:
s="玖";
break;
}
return s;
}
public static string RMB(double rmb)
{
string r=rmb.ToString ("0.00");
int dian=r.IndexOf (".");
string r1=r.Substring (0,dian);
string r2=r.Substring (dian+1 );
char[] mychar=r1.ToCharArray ();
Array.Reverse (mychar);
string y="元拾佰仟萬拾佰仟";
string yuan="";
char[] myc=new char[y.Length *2];
bool bol=false;
//取整数部分
#region 取整数部分
for (int n=0;n<y.Length ;n++)
{
if (n<mychar.Length )
{
//Console.WriteLine (mychar[n]);
//yuan+=" "+yget(Convert.ToInt16(mychar[n].ToString()))+" "+y.Substring (n,1);
myc[n*2]=Convert.ToChar (y.Substring (n,1));
myc[n*2+1]=Convert.ToChar (yget(Convert.ToInt16(mychar[n].ToString())));
}
else
{
myc[n*2]=Convert.ToChar (y.Substring (n,1));
if (bol==false)
{
myc[n*2+1]='×';//⊕
bol=true;
}
else
{
myc[n*2+1]=' ';
}
}
}
Array.Reverse (myc);
for(int yu=0;yu<myc.Length ;yu++)
{
yuan+=" "+myc[yu]+" ";
}
#endregion
//Console.WriteLine("mychar");
//Console.WriteLine (" M "+r1+" ");
//Console.WriteLine (r1);
//Console.WriteLine (r2);
string jiaofen="";
string j="角分";
for(int i=0;i<r2.Length ;i++)
{
jiaofen+=" "+yget(Convert.ToInt16(r2.Substring (i,1)))+" "+j.Substring (i,1);
}
//Console.WriteLine (jiaofen);
//Console.WriteLine(yuan);
//Console.WriteLine ();
return yuan+jiaofen+"整";
}