日期:2014-05-18 浏览次数:20995 次
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; }