zoukankan      html  css  js  c++  java
  • 中文转数字

     

             private void button1_Click(object sender, EventArgs e)
            {
                cpCount ="二十万零二百五";
                MessageBox.Show(cpCount);
            }

            string _cpCount;

            public string cpCount
            {
                get { return _cpCount + ""; }

                set
                {
                    string s = value;
                    string ic="";
                    int t=0;
                    int tmax = 0;


                    string zs = "00000000000000000000000000";

                    string ss="零一二三四五六七八九";
                    string tt = "十百千万十百千亿";
                    if (tt.IndexOf(s[0]) != -1) s = "一" + s;
                   
                    for (int i=s.Length-1;i>=0;i--)
                    {
                        char c=s[i];

                        if (tt.IndexOf(c) >-1)
                        {
                            t = tt.IndexOf(c) + 1;
                            tmax = t > tmax ? t : tmax;
                        }
                        else
                        {
                            int d = ss.IndexOf(c);
                            if (d == 0) continue;
                            if (d == -1) { _cpCount="数据有误!"; return; }
                            int p = tmax > t ? t + tmax : t;
                            ic =d+zs.Substring(0, p-ic.Length)+ic;
                   
                        }

                    }

                    _cpCount = ic.ToString();
                }
            }

  • 相关阅读:
    配置Kickstart无人值守安装centos5.9 天高地厚
    数据库是什么,它是做什么用的? 天高地厚
    Mysql主从复制 天高地厚
    android开发中eclipse里xml的自动提示
    "error: device not found" and "error:device offline"
    gentoo中emerge失效:File "/usr/bin/emerge", line 43
    android:修改preference中view属性
    gerrit上利用sshkeygen公钥
    git 基本命令介绍
    prebuilt/linuxx86/toolchain/armeabi4.4.3/bin/armeabigcc: /lib/libc.so.6: version `GLIBC_2.11' not found:解决办法
  • 原文地址:https://www.cnblogs.com/dashi/p/4034746.html
Copyright © 2011-2022 走看看