C#中文转简拼
nuget引用
public static string ChineseCharToPingyin(string str) { if (null == str || str.Length <= 0) { return ""; } StringBuilder sb = new StringBuilder(""); ChineseChar chineseChar = null; for (int i = 0; i < str.Length; i++) { try { chineseChar = new ChineseChar(str[i]); if (null != chineseChar.Pinyins[0] && chineseChar.Pinyins[0].Length > 0) sb.Append(chineseChar.Pinyins[0][0]); } catch { sb.Append(str[i]); } } return sb.ToString(); }