• 刚写的 一个数字转中文的小函数,比较常用,自己用~~


    一共仨控件: mNum mTxt1 mTxt2 这个 button就不算在里了。。

            private void button1_Click(object sender, EventArgs e)
            {
                string m = this.mTxt1.Text.ToString();
                int n = Convert.ToInt32(this.mNum.Text.ToString());
                for (int i = 0; i <= n; i++)
                {
                    m = m.Replace("第" + i + "位", "第" + retNum(i.ToString()) + "位");
                }

                this.mTxt2.Text = m;
            }

            public string retNum(string n)
            {
                if (n.Length == 2)
                {
                    string n1 = n.Substring(0, 1);
                    string n2 = n.Substring(1, 1);
                    if (n1 == "1")
                    {
                        n1 = "";
                    }
                    if (n2 == "0")
                    {
                        n2 = "";
                    }
                    return retOneNum(n1) + "十" + retOneNum(n2);

                }
                else
                {
                    return retOneNum(n);
                }
            }

            public string retOneNum(string n)
            {
                string k = n;

                k = k.Replace("1", "一");
                k = k.Replace("2", "二");
                k = k.Replace("3", "三");
                k = k.Replace("4", "四");
                k = k.Replace("5", "五");
                k = k.Replace("6", "六");
                k = k.Replace("7", "七");
                k = k.Replace("8", "八");
                k = k.Replace("9", "九");
                k = k.Replace("0", "零");

                return k;
            }

    ---------------------------------------------
    生活的意义并不是与他人争高下,而在于享受努力实现目标的过程,结果是对自己行动的嘉奖。
    ↑面的话,越看越不痛快,应该这么说:

    生活的意义就是你自己知道你要做什么,明确目标。没有目标,后面都是瞎扯!
  • 相关阅读:
    SpringMvc
    Spring-Aop
    Spring-IOC
    Spring模块划分
    队列
    稀疏数组
    数据结构
    Nginx配置实例
    Nginx常用命令
    视频断点播放:h5+jquery
  • 原文地址:https://www.cnblogs.com/pengchenggang/p/1736847.html
Copyright © 2020-2023  润新知