惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Know Your Adversary
Know Your Adversary
云风的 BLOG
云风的 BLOG
Recent Announcements
Recent Announcements
F
Fortinet All Blogs
B
Blog
罗磊的独立博客
宝玉的分享
宝玉的分享
Vercel News
Vercel News
Martin Fowler
Martin Fowler
N
Netflix TechBlog - Medium
P
Proofpoint News Feed
T
Threatpost
Security Latest
Security Latest
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Stack Overflow Blog
Stack Overflow Blog
I
Intezer
P
Privacy International News Feed
D
Docker
月光博客
月光博客
博客园 - 三生石上(FineUI控件)
M
MIT News - Artificial intelligence
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
L
Lohrmann on Cybersecurity
Google DeepMind News
Google DeepMind News
The Last Watchdog
The Last Watchdog
A
Arctic Wolf
IT之家
IT之家
S
SegmentFault 最新的问题
S
Securelist
博客园 - 叶小钗
N
News and Events Feed by Topic
F
Full Disclosure
Security Archives - TechRepublic
Security Archives - TechRepublic
Engineering at Meta
Engineering at Meta
Hacker News: Ask HN
Hacker News: Ask HN
博客园 - Franky
GbyAI
GbyAI
AI
AI
Y
Y Combinator Blog
WordPress大学
WordPress大学
Latest news
Latest news
Microsoft Security Blog
Microsoft Security Blog
人人都是产品经理
人人都是产品经理
N
News | PayPal Newsroom
The Cloudflare Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
I
InfoQ

博客园 - g無s所p畏

vs2019(vs2017)配置菜单发布nuget包 不同应用共享redis应用,但分数据库存储数据 常用JS判断各种格式,以及替换函数等 jquery工作小笔记:jquery获取页面上控件的值 Asp.net 常用的正则表达式汇集 SCOPE_IDENTITY()代替 @@IDENTITY iis预览.net发布的网站时遇到的莫名问题:无资源行。 sql 自动补位 将公历转换成农历的类_C# 2007年工作总结 .NET中AJAX乱码问题解决 图片无缝滚动 千万级通用的分页存储过程 生成验证码图片(含模糊背景) 求助:C#读取邮件 求助:一个能够验证到时、分甚至秒的脚本表达式 SQL中触发器实例讲解 SQL中CONVERT转化函数的用法 获取远程服务器的ip地址以及地区地址
数字人民币(RMB)转化为大写字母
g無s所p畏 · 2007-12-21 · via 博客园 - g無s所p畏

using System.Text;

/// <summary>
/// ToChineseValue 的摘要说明
/// 人民币(RMB)转化为大写字母
/// </summary>
public class ToChineseValue
{
    private enum chineseChar { 零, 壹, 贰, 叁, 肆, 伍, 陆, 柒, 捌, 玖 };
    private enum charValue { 个 = 1, 十, 百, 千 };
    private enum c { 元 = 1, 万, 亿, 兆 };
    private enum afterPoint { 角, 分 };


    public ToChineseValue()
    {
        //
        // TODO: 在此处添加构造函数逻辑
        //
    }
    public static string toChineseChar(decimal d)
    {
        decimal flag = 0;
        if (d < 0)
        {
            flag = d;
            d = -d;
        }

        string strChinese = "";
        string nextString = "";

        System.Globalization.NumberFormatInfo fmat = new System.Globalization.NumberFormatInfo();
        fmat.CurrencyDecimalDigits = 2;
        fmat.CurrencySymbol = "";
        fmat.CurrencyGroupSizes = new int[] { 4, 4, 4, 4 };
        fmat.CurrencyGroupSeparator = ",";

        string strx = d.ToString("c", fmat);
        string[] afterArray = strx.ToString().Split('.');

        char[] prePoint = afterArray[0].ToCharArray();
        char[] nextChar = afterArray[1].ToCharArray();

        if (System.Convert.ToDecimal(afterArray[0].ToString()) == 0)
        { strChinese = ""; }
        else
        {
            string[] str = afterArray[0].ToString().Split(',');
            int Num = str.Length;
            //交错数组用来放四个一组的数组
            char[][] part = new char[Num][];
            for (int i = 0; i < str.Length; i++)
            {
                part[i] = str[i].ToCharArray();
            }
            for (int i = 0; i < Num; i++)
            {
                for (int j = 0; j < part[i].Length; j++)
                {
                    //用枚举完成汉字的转换
                    strChinese += ((chineseChar)int.Parse(part[i][j].ToString())).ToString();
                    //用枚举完成单位: 个 十 百 千
                    strChinese += ((charValue)(part[i].Length - j)).ToString();
                }
                //以下为处理元 万 亿 兆
                strChinese += ((c)(part.Length - i)).ToString();
            }
        }
        //处理点号后面的小数部分       
        if (System.Convert.ToDecimal(afterArray[1].ToString()) == 0 && System.Convert.ToDecimal(afterArray[0].ToString()) != 0)
        {
            nextString = "整";
        }
        else
        {
            for (int i = 0; i < 2; i++)
            {
                int t = int.Parse(nextChar[i].ToString());
                nextString += ((chineseChar)int.Parse(nextChar[i].ToString())).ToString();
                nextString += ((afterPoint)(i)).ToString();
                if (t == 0)
                {
                    StringBuilder str = new StringBuilder(nextString);
                    nextString = str.Replace("零零", "零").ToString();
                    nextString = str.Replace("零角零分", "零元").ToString();
                }
            }
        }
        StringBuilder sb = new StringBuilder(strChinese);
        for (int i = 0; i < 4; i++)
        {
            strChinese = sb.Replace("个", "").ToString();
            strChinese = sb.Replace("零元", "元").ToString();
            strChinese = sb.Replace("零万", "万").ToString();
            strChinese = sb.Replace("亿万", "亿").ToString();
            strChinese = sb.Replace("零亿", "亿").ToString();
            strChinese = sb.Replace("零十", "零").ToString();
            strChinese = sb.Replace("零百", "零").ToString();
            strChinese = sb.Replace("零千", "零").ToString();
            strChinese = sb.Replace("零零", "零").ToString();
            strChinese = sb.Replace("零角零分", "整").ToString();
        }
        if (flag >= 0)
        {
            return strChinese + nextString;
        }
        return "负" + strChinese + nextString;
    }
}