代码
/// <summary>
/// 将字符串中的数字字符串转换成简体中文
/// </summary>
/// <param name="digital"></param>
/// <returns></returns>
public static string ConvertDigitalToChinese(string digital)
{
char[] chrChinese = { 'O', '一', '二', '三', '四', '五', '六', '七', '八', '九' };
char[] digitalArr = digital.ToCharArray();
string result = string.Empty;
foreach (char c in digitalArr)
{
switch (c)
{
case '0':
result += chrChinese[0].ToString();
break;
case '1':
result += chrChinese[1].ToString();
break;
case '2':
result += chrChinese[2].ToString();
break;
case '3':
result += chrChinese[3].ToString();
break;
case '4':
result += chrChinese[4].ToString();
break;
case '5':
result += chrChinese[5].ToString();
break;
case '6':
result += chrChinese[6].ToString();
break;
case '7':
result += chrChinese[7].ToString();
break;
case '8':
result += chrChinese[8].ToString();
break;
case '9':
result += chrChinese[9].ToString();
break;
default:
result += c.ToString();
break;
}
}
return result;
}
/// <summary>
/// 将数字转换成简体中文
/// </summary>
/// <param name="digital"></param>
/// <returns></returns>
public static string ConvertDigitalToChinese(int digital)
{
char[] chrChinese = { 'O', '一', '二', '三', '四', '五', '六', '七', '八', '九' };
char[] digitalArr = digital.ToString().ToCharArray();
string result = string.Empty;
foreach (char c in digitalArr)
{
result += chrChinese[c - '0'];
result += chrChinese[System.Convert.ToInt32(c.ToString())];
}
return result;
}
/// 将字符串中的数字字符串转换成简体中文
/// </summary>
/// <param name="digital"></param>
/// <returns></returns>
public static string ConvertDigitalToChinese(string digital)
{
char[] chrChinese = { 'O', '一', '二', '三', '四', '五', '六', '七', '八', '九' };
char[] digitalArr = digital.ToCharArray();
string result = string.Empty;
foreach (char c in digitalArr)
{
switch (c)
{
case '0':
result += chrChinese[0].ToString();
break;
case '1':
result += chrChinese[1].ToString();
break;
case '2':
result += chrChinese[2].ToString();
break;
case '3':
result += chrChinese[3].ToString();
break;
case '4':
result += chrChinese[4].ToString();
break;
case '5':
result += chrChinese[5].ToString();
break;
case '6':
result += chrChinese[6].ToString();
break;
case '7':
result += chrChinese[7].ToString();
break;
case '8':
result += chrChinese[8].ToString();
break;
case '9':
result += chrChinese[9].ToString();
break;
default:
result += c.ToString();
break;
}
}
return result;
}
/// <summary>
/// 将数字转换成简体中文
/// </summary>
/// <param name="digital"></param>
/// <returns></returns>
public static string ConvertDigitalToChinese(int digital)
{
char[] chrChinese = { 'O', '一', '二', '三', '四', '五', '六', '七', '八', '九' };
char[] digitalArr = digital.ToString().ToCharArray();
string result = string.Empty;
foreach (char c in digitalArr)
{
result += chrChinese[c - '0'];
result += chrChinese[System.Convert.ToInt32(c.ToString())];
}
return result;
}