当前位置:编程学习 > html/css >>

获取汉字首字母,多音拼音,递归实现(性能最好,最完善)

<p> </p><p>using Microsoft.International.Converters.PinYinConverter; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks;</p><p>namespace ConsoleApplication1 {     class Program     {         static void Main(string[] args)         {             List<string> a = PinYingHelper.GetPYList("l奇】");             List<string> b = PinYingHelper.GetPYFullList("l奇】");             List<string> c = PinYingHelper.GetPYInitialList("l奇】");         }     } }</p><p> </p><p> </p><p> </p><p>using Microsoft.International.Converters.PinYinConverter; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks;</p><p>namespace ConsoleApplication1 {     public class PinYingHelper     {         #region  获取汉字首字母包含多音如 “奇” 返回 new List<string>{"Q","J"};         /// <summary>         /// 获取汉字首字母包含多音         /// </summary>         /// <param name="str"></param>         /// <returns></returns>         public static List<string> GetPYInitialList(string str)         {             List<string> list = new List<string>();             return GetPYInitialList(GetPYList(str));         }</p><p>        /// <summary>         /// 获取汉字首字母包含多音         /// </summary>         /// <param name="pyList">传入GetPY这个方法返回的对象</param>         /// <returns></returns>         public static List<string> GetPYInitialList(List<string> pyList)         {             List<string> list = new List<string>();             foreach (string py in pyList)             {                 string[] strs = py.Split('$');                 StringBuilder sb = new StringBuilder();                 foreach (string s in strs)                 {                     if (s.Length > 0)                     {                         sb.Append(s.Substring(0, 1));                     }                 }                 list.Add(sb.ToString());             }             return list;         }         #endregion</p><p>        #region 获取拼音包含多音,如"奇"返回new List<string>{"QI","JI"};         /// <summary>         /// 获取拼音包含多音         /// </summary>         /// <param name="pyList">传入GetPY这个方法返回的对象</param>         /// <returns></returns>         public static List<string> GetPYFullList(List<string> pyList)         {             List<string> list = new List<string>();             foreach (string py in pyList)             {            
补充:web前端 , HTML/CSS  ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,