首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

C#中有没有方法得到汉字的拼音解决方案

2012-05-20 
C#中有没有方法得到汉字的拼音如题,有没有办法得到汉字的拼音是怎么样,[解决办法]参考http://www.cnblogs.

C#中有没有方法得到汉字的拼音
如题,有没有办法得到汉字的拼音是怎么样,


[解决办法]
参考http://www.cnblogs.com/islands/articles/1231613.html
[解决办法]
C# 简体与繁体互转,汉字取拼音、笔画、读音
C# 获取汉字拼音首字母
[解决办法]
引入这个dll

C# code
public static string ToPY(this string str)        {            string temp = string.Empty;            foreach (char i in str)            {                try                {                    ChineseChar chineseChar = new ChineseChar(i);                    string t = chineseChar.Pinyins[0].ToString();                    temp += t.Substring(0, t.Length - 1);                }                catch                {                    temp += i.ToString();                }            }            return temp;        }        public static string ToShortPY(this string str)        {            string temp = string.Empty;            foreach (char i in str)            {                try                {                    ChineseChar chineseChar = new ChineseChar(i);                    string t = chineseChar.Pinyins[0].ToString();                    temp += t.Substring(0, 1);                }                catch                {                    temp += i.ToString();                }            }            return temp;        } 

热点排行