public string NumToChinese(string x){//数字转换为中文后的数组 //转载请注明来自 http://www.uzhanbao.comstring[] P_array_num = new string[] { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" };//为数字位数建立一个位数组string[] P_array_digit = new string[] { "", "拾", "佰", "仟" };//为数字单位建立一个单位数组string[] P_array_units = new string[] { "", "万", "亿", "万亿" };string P_str_returnValue = ""; //返回值int finger = 0; //字符位置指针int P_int_m = x.Length % 4; //取模int P_int_k = 0;if (P_int_m > 0)P_int_k = x.Length / 4 + 1;elseP_int_k = x.Length / 4;//外层循环,四位一组,每组最后加上单位: ",万亿,",",亿,",",万,"for (int i = P_int_k; i > 0; i--){int P_int_L = 4;if (i == P_int_k && P_int_m != 0)P_int_L = P_int_m;//得到一组四位数string four = x.Substring(finger, P_int_L);int P_int_l = four.Length;//内层循环在该组中的每一位数上循环for (int j = 0; j < P_int_l; j++){//处理组中的每一位数加上所在的位int n = Convert.ToInt32(four.Substring(j, 1));if (n == 0){if (j < P_int_l - 1 && Convert.ToInt32(four.Substring(j + 1, 1)) > 0 && !P_str_returnValue.EndsWith(P_array_num[n]))P_str_returnValue += P_array_num[n];}else{if (!(n == 1 && (P_str_returnValue.EndsWith(P_array_num[0]) | P_str_returnValue.Length == 0) && j == P_int_l - 2))P_str_returnValue += P_array_num[n];P_str_returnValue += P_array_digit[P_int_l - j - 1];}}finger += P_int_L;//每组最后加上一个单位:",万,",",亿," 等if (i < P_int_k) //如果不是最高位的一组{if (Convert.ToInt32(four) != 0)//如果所有4位不全是0则加上单位",万,",",亿,"等P_str_returnValue += P_array_units[i - 1];}else{//处理最高位的一组,最后必须加上单位P_str_returnValue += P_array_units[i - 1];}}return P_str_returnValue;}

c#数字转换为大写汉字相关推荐

  1. SQLserver数字转换为大写汉字

    通过创建函数,这个函数输出的值是每个汉字后面都加入空格. 如不需要只要将最后定义的@min.@max.@str 变量及后面拼接的代码去掉即可,并且最后return的应该为@n_str. CREATE ...

  2. h5将数字翻译为大写汉字_JS将数字转换为大写汉字人民币

    functionconvertCurrency(currencyDigits) {//Constants: var MAXIMUM_NUMBER = 99999999999.99;//Predefin ...

  3. python数字转换为大写中文_python 人民币数字转汉字大写金额

    1 ''' 2 人民币数字转大写汉字3 ''' 4 5 #coding: utf-8 6 importwarnings7 from decimal importDecimal8 9 def cncur ...

  4. VB:将数字转换为大写中文

    方法1: 程序代码: Const strN = "零壹贰叁肆伍陆柒捌玖" Const strG = "拾佰仟万亿" Const intN = "012 ...

  5. python数字转中文大写_python 数字转换为大写

    在会计的时候,用到将数字转换为大写,也就是讲数字转为汉字 外汇出入金流程https://www.fx61.com/supportclass cnumber: cdict = {} gdict = {} ...

  6. JS 实现数字转换为大写中文金额

    数字转换为大写中文金额 function convertCurrency(money) { //汉字的数字 var cnNums = new Array('零', '壹', '贰', '叁', '肆' ...

  7. 人民币数字转大写汉字

    ''' 人民币数字转大写汉字 '''# coding: utf-8 import warnings from decimal import Decimaldef cncurrency(value, c ...

  8. 将阿拉伯数字转换为大写汉字

    将阿拉伯数字转换为大写汉字,严谨写法: 学习链接 function toChineseNumeral(num) {let changeNum = ['零', '一', '二', '三', '四', ' ...

  9. 数字金额转换为大写金额python_python 数字转换为大写

    在会计的时候,用到将数字转换为大写,也就是讲数字转为汉字 外汇出入金流程https://www.fx61.com/supportclass cnumber: cdict = {} gdict = {} ...

最新文章

  1. linux 中samba账号登录密码,ubuntu下的Samba配置:使每个用户可以用自己的用户名和密码登录自己的home目录...
  2. Java背景颜色怎么设成随机的_JS实现随机改变背景颜色
  3. 魅族android6.0,【魅族魅蓝5s评测】迷人Flyme 安卓6.0提升流畅度_手机评测-中关村在线...
  4. php 二维数组值相加,php二维数组指定某元素后面的值是和前面的值相加起来的...
  5. python字符串的美化_Python构造自定义方法来美化字典结构输出
  6. Myeclipse/eclipse 安装查看class文件的插件
  7. 手把手教你爬虫requests实战演练——python篇
  8. 斯坦福大学2019年NLP课程上线,下周二开课 | 附PPT+视频
  9. apache在线升级yum_linux yum安装apache
  10. C#获取当前时区转换方法
  11. PS中标尺工具在哪里
  12. Linux Thermal机制源码分析之Thermal zone
  13. 一文搞懂CSS 3D动画效果
  14. VideoCodec 入门篇 - 00 (编解码简介)
  15. 计算机之网络基础 7层网络模型总结
  16. MAC下Apktool、dex2jar、jd-gui的安装和反编译、回编译、重新签名简单使用
  17. C语言关系运算符详解
  18. 数据采集之全埋点数据采集分析方法的一些整理
  19. UE、UI、 IA和IxD傻傻分不清
  20. 2017-2018-1(实变函数56, 点集拓扑56)

热门文章

  1. 前端为什么这么麻烦之浏览器
  2. Linux C/C++ 开发(学习笔记十一 ):TCP服务器(并发网络网络编程 一请求一线程)
  3. move语言学习(基础篇)
  4. 给我推荐5款桌面整理软件
  5. Cesium加载海量倾斜模型优化配置
  6. 太阳能电池技术新突破,眼镜也能当充电器
  7. 如何选择该用Ubuntu还是centos呢?
  8. Bilibili直播的弹幕数据包解析
  9. 执法记录仪提示内存不足时怎么办?快速解决方法
  10. 一日一Shader·天空镜面反射【SS_26】