C#汉字拼音检索

1、下载安装包

链接:https://pan.baidu.com/s/16JXxMUlCaKsRSIc-beFobA
提取码:jx0p
本机无须安装,需要引用的类与API已经整理出来啦~

注:若需其他类型的检索,请安装相应的包,引用安装包下的类库即可,第一个包汉字,第二个包繁体...

2、类库使用

一、引用DLL类库

二、效果

三、完整代码

 1         private void button1_Click(object sender, EventArgs e)
 2         {
 3             //1、引用命名空间
 4             //using Microsoft.International.Converters.PinYinConverter;
 5             //2、获取用户输入
 6             string user_input = txtSC.Text.Trim();
 7             txtPy.Text = GetPyFromChineseString(user_input);
 8         }
 9         private string GetPyFromChineseString(string user_input)
10         {
11             StringBuilder sb = new StringBuilder();
12             for (int i = 0; i < user_input.Length; i++)
13             {
14                 ChineseChar cnChar = new ChineseChar(user_input[i]);
15                 if (cnChar.Pinyins.Count>0) //有拼音
16                 {
17                     string py = cnChar.Pinyins[0];
18                     sb.Append(py.Substring(0, py.Length - 1)); //最后一个数字不要
19                 }
20             }
21             return sb.ToString();
22         }

四、完整项目地址

链接:https://pan.baidu.com/s/1HNPH8-PiaY5RalN19dKV3g
提取码:9pdz

 推荐超全NPOI资料在这里哦!~https://www.cnblogs.com/chenyanbin/p/10832614.html

猜你喜欢

转载自www.cnblogs.com/chenyanbin/p/10850915.html
今日推荐