zoukankan      html  css  js  c++  java
  • 中文繁简互换以及获取中文字符串首字母

    1、经常会遇到简体变繁体、繁体变简体和取中文字符串首字母的需求,最近整理了一个公共类,给大家分享。运行效果:

    2、调用方法,代码如下:

            /// <summary>
            /// 简体变繁体
            /// </summary>
            private void button1_Click(object sender, EventArgs e)
            {
                if (!string.IsNullOrWhiteSpace(textBox1.Text))
                    textBox2.Text = textBox1.Text.ToTraditional();
                else
                    MessageBox.Show("请输入简体字!");
            }
    
            /// <summary>
            /// 繁体变简体
            /// </summary>
            private void button2_Click(object sender, EventArgs e)
            {
                if (!string.IsNullOrWhiteSpace(textBox2.Text))
                    textBox1.Text = textBox2.Text.ToSimplified();
                else
                    MessageBox.Show("请输入繁体字!");
            }
    
            //取首字母
            private void button3_Click(object sender, EventArgs e)
            {
                if (!string.IsNullOrWhiteSpace(textBox3.Text))
                    textBox4.Text = textBox3.Text.GetChineseFristSpell().ToUpper();
                else
                    MessageBox.Show("请在左侧框输入汉字!");
            }

    3、其中简繁互换,引用了Microsoft.VisualBasic。完整工具类及案例,已整理发布,公共类名称为ChineseUtils。下载链接(无需积分):http://download.csdn.net/detail/kehaigang29/8868967

  • 相关阅读:
    闭包问题小总结
    git常用命令总结
    数组对象方法的使用
    JS截取URL参数
    CSS清除浮动&内容居中&文字溢出
    网址大全
    any more
    下载网页视频
    下载无损音乐
    "前端" 宝藏网站
  • 原文地址:https://www.cnblogs.com/ManchesterUnitedFootballClub/p/4621193.html
Copyright © 2011-2022 走看看