zoukankan      html  css  js  c++  java
  • 汉字转拼音 城市绑定

    引用 程序集

    ChnCharInfo.dll

    using Microsoft.International.Converters.PinYinConverter;

    转换方法

    public static string ToPinyin(string hanzi)
            {
                char[] ch = hanzi.ToArray();
                string pinyinStr = "";
                foreach (char c in ch)
                {
                    if (ChineseChar.IsValidChar(c))
                    {
                        ChineseChar chineseChar = new ChineseChar(c);
                        ReadOnlyCollection<string> pinyin = chineseChar.Pinyins;
                        pinyinStr += (pinyin[0].Substring(0, pinyin[0].Length - 1));
                    }
                    else
                    {
                        pinyinStr += c.ToString();
                    }
                }
                return pinyinStr.ToLower();
            }

    城市绑定的特殊效果

    <div id="con_province_2" style="display: none;">
                                    <ul class="cdcomment">
                                        @{
                                            foreach (Entity.TXDai.Provinces item in Provinces)
                                            {
                                                string pinyinStr = Common.ToPinyin(item.Province);
                                                if (pinyinStr[0] == 'a' || pinyinStr[0] == 'b' || pinyinStr[0] == 'c' || pinyinStr[0] == 'd' || pinyinStr[0] == 'f')
                                                {
                                            <li><a href="javascript:void(0);" data="@item.ProvinceID">@item.Province</a></li>
                                                }
                                            }
                                        }
                                    </ul>
                                </div>

  • 相关阅读:
    如何让自己拥有两年工作经验
    示波器入门使用方法
    模板显式、隐式实例化和(偏)特化、具体化的详细分析
    Dynamics CRM 2013 初体验(5):Business Rule
    Tomcat搭建
    岁月,时光,现实
    数据结构之链表单向操作总结
    iptables学习笔记
    知无涯者(The Man Who Knew Infinity)
    Dynamics CRM2016 Web API之Expand related entities &amp; $ref &amp; $count
  • 原文地址:https://www.cnblogs.com/eric-gms/p/4054203.html
Copyright © 2011-2022 走看看