/// <summary>
/// 本類實現阿拉伯數字到大寫中文的轉換
/// 該類沒有對非法數字進行判別
/// </summary>
public class ChineseNum
{
//小寫轉大寫
public static string GetChineseNum(string p_num)
{
ChineseNum cn = new ChineseNum();
return cn
}
//小寫金額轉大寫金額
public static string GetUpperMoney(double p_Money)
{
ChineseNum cn = new ChineseNum();
return cn
}
//轉換數字
private char CharToNum(char x)
{
string stringChnNames =
string stringNumNames =
return stringChnNames[stringNumNames
}
//轉換萬以下整數
private string WanStrToInt(string x)
{
string[] stringArrayLevelNames = new string[
string ret =
int i;
for (i = x
if (x[i] ==
{
ret = CharToNum(x[i]) + ret;
}
else
{
ret = CharToNum(x[i]) + stringArrayLevelNames[x
}
while ((i = ret
{
ret = ret
}
if (ret[ret
{
ret = ret
}
if (ret
{
ret = ret
}
return ret;
}
//轉換整數
private string StrToInt(string x)
{
int len = x
string ret
if (len <=
{
ret = WanStrToInt(x);
}
else if (len <=
{
ret = WanStrToInt(x
temp = WanStrToInt(x
if (temp
ret +=
else
ret += temp;
}
else
{
ret = WanStrToInt(x
temp = WanStrToInt(x
if (temp
{
ret +=
}
else
{
ret += temp;
}
ret +=
temp = WanStrToInt(x
if (temp
{
ret +=
}
else
{
ret += temp;
}
}
int i;
if ((i = ret
{
ret = ret
}
while ((i = ret
{
ret = ret
}
if (ret[ret
{
ret = ret
}
return ret;
}
//轉換小數
private string StrToDouble(string x)
{
string ret =
for (int i =
{
ret += CharToNum(x[i]);
}
return ret;
}
private string NumToChn(string x)
{
if (x
{
return
}
string ret =
if (x[
{
ret =
x = x
}
if (x[
{
x =
}
if (x[x
{
x = x
}
if (x
{
ret += StrToInt(x
}
else
{
ret += StrToInt(x);
}
return ret;
}
//金額轉換
private string GetMoneyChinese(Double Money)
{
int i;
string mstrSource;
if (Money ==
{
return
}
mstrSource = Money
i = mstrSource
if (i >
if (mstrSource
mstrSource = NumstrToChinese(mstrSource);
if (mstrSource
//負
if (Money <
{
mstrSource =
}
mstrSource = mstrSource
mstrSource = mstrSource
mstrSource = mstrSource
mstrSource = mstrSource
mstrSource = mstrSource
mstrSource = mstrSource
mstrSource = mstrSource
mstrSource = mstrSource
mstrSource = mstrSource
mstrSource = mstrSource
mstrSource = mstrSource
mstrSource = mstrSource
mstrSource = mstrSource
mstrSource = mstrSource
mstrSource = mstrSource
mstrSource = mstrSource
mstrSource = mstrSource
mstrSource = mstrSource
if (mstrSource
{
mstrSource = mstrSource +
}
return mstrSource;
}
//金額轉換
private string NumstrToChinese(string numstr)
{
int i;
int j;
string mstrChar;
string[] mstrFlag = new string[
string mstrReturn =
bool mblnAddzero = false;
mstrFlag[
mstrFlag[
mstrFlag[
mstrFlag[
for (i =
{
j = numstr
mstrChar = numstr
if (mstrChar !=
if (mstrChar ==
{
mstrReturn = mstrReturn +
mblnAddzero = true;
}
if (j ==
{
if (mstrReturn
{ mstrReturn = mstrReturn
else
{ mstrReturn = mstrReturn +
}
if (j ==
{
if (mstrReturn
{ mstrReturn = mstrReturn
else
{ mstrReturn = mstrReturn +
//元
}
if (j ==
{
if (mstrReturn
{
if (mstrReturn
{
if (mstrReturn
{ mstrReturn = mstrReturn
else
{ mstrReturn = mstrReturn +
}
}
else
{
if (mstrReturn
{ mstrReturn = mstrReturn
else
{ mstrReturn = mstrReturn +
}
}
if (j ==
{
if (mstrReturn
{ mstrReturn = mstrReturn
else
{ mstrReturn = mstrReturn +
}
if (j ==
if (j ==
if (mstrChar !=
}
if (mstrReturn
if (mstrReturn
if (mstrReturn
if (mstrReturn
return mstrReturn;
}
}
From:http://tw.wingwit.com/Article/program/net/201311/13523.html