汉字转首拼
/// <summary> /// 字符串转首拼 /// </summary> /// <param name="str">要转的汉字字符串</param> /// <param name="str">注*:添加ChnCharInfo.dll</param> /// <returns></returns> public string PYZG(string str) { char[] carr = str.ToCharArray(); str = new string(carr); string py = ""; foreach (var item in str) { if (item >= 0x4e00 && item <= 0x9fbb) { ChineseChar chn = new ChineseChar(item); py += chn.Pinyins[0].Substring(0, 1).ToLower(); } else { py += item; } } py += DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString(); return py; }
欢迎评论。。。。让我看到你的反馈。。。。