zoukankan      html  css  js  c++  java
  • 汉字转换为拼音

    1先引用ChnCharInfo.dll(这个可以在网上下到,如果实在下载不到!直接Q,我发给你)

    public class ChineseToPinYins
        {
            public static Dictionary<int, string> ChineseToPinYin(Dictionary<int, string> chinese)
            {
                Dictionary<int, string> newChinese = new Dictionary<int, string>();
                int xuhao = 0;
                foreach (var item in chinese)
                {
                    string SZM = "";
                    foreach (char c in item.Value.Trim())
                    {
                        ChineseChar chineschar = new ChineseChar(c);
                        SZM += chineschar.Pinyins[0][0];
                    }
                    if (newChinese.ContainsValue(SZM))
                    {
                        newChinese.Add(item.Key, SZM);
                    }
                    else 
                    {
                        xuhao++;
                        newChinese.Add(item.Key, SZM + xuhao.ToString());
                    }
                }
    
                return newChinese;
            }
        }
    

     这个方法实现的功能是,把汉字的首字母拼接,如果首字母相同则用序号依次添加

  • 相关阅读:
    10.28
    10.29
    11.05周四
    数据库增删改查
    11.03Tuesday
    11.10
    连接数据库
    10.30
    11.04周三
    10.27
  • 原文地址:https://www.cnblogs.com/guozhe/p/3014641.html
Copyright © 2011-2022 走看看