/// <summary> /// 用来获得一个字的拼音首字母 /// </summary> /// <param name="cnChar">一个字</param> /// <returns></returns> public static string GetInitialSpell(string cnChar) { if (string.IsNullOrEmpty(cnChar)) { return(cnChar); } return(ALSpell.GetSpell(cnChar[0])); }
/// <summary> /// 获得姓名的缩写,例如zhangs /// </summary> /// <param name="cnChar"></param> /// <returns></returns> public static string GetNameSpells(string cnChar) { if (string.IsNullOrEmpty(cnChar)) { return(cnChar); } string output = ""; for (int i = 0; i < cnChar.Length; i++) { output += (i == 0 ? ALSpell.GetSpells(cnChar[i]).ToLower() : ALSpell.GetSpell(cnChar[i]).ToLower()); } return(output); }
/// <summary> /// 获得中文字符串的首字母 /// </summary> /// <param name="str">中文字符串</param> /// <returns></returns> public static string GetInitialSpells(string str) { return(ALSpell.GetSpell(str)); }