转换汉子首字母类 CreatChinaSpell
public class CreatChinaSpell { public static string GetChineseFirstChar(string chineseStr) { StringBuilder sb = new StringBuilder(); int length = chineseStr.Length; for (int i = 0; i < length; i++) { string chineseChar = chineseStr.Substring(i, 1); sb.Append(GetpyChar(chineseChar)); } return sb.ToString(); } private static string GetpyChar(string chineseChar) { string result = string.Empty; if (chineseChar.CompareTo("帀") >= 0) { result = "Z"; } else if (chineseChar.CompareTo("丫") >= 0) { result = "Y"; } else if (chineseChar.CompareTo("夕") >= 0) { result = "X"; } else if (chineseChar.CompareTo("屲") >= 0) { result = "W"; } else if (chineseChar.CompareTo("他") >= 0) { result = "T"; } else if (chineseChar.CompareTo("仨") >= 0) { result = "S"; } else if (chineseChar.CompareTo("呥") >= 0) { result = "R"; } else if (chineseChar.CompareTo("七") >= 0) { result = "Q"; } else if (chineseChar.CompareTo("妑") >= 0) { result = "P"; } else if (chineseChar.CompareTo("噢") >= 0) { result = "O"; } else if (chineseChar.CompareTo("拏") >= 0) { result = "N"; } else if (chineseChar.CompareTo("嘸") >= 0) { result = "M"; } else if (chineseChar.CompareTo("垃") >= 0) { result = "L"; } else if (chineseChar.CompareTo("咔") >= 0) { result = "K"; } else if (chineseChar.CompareTo("丌") >= 0) { result = "J"; } else if (chineseChar.CompareTo("铪") >= 0) { result = "H"; } else if (chineseChar.CompareTo("旮") >= 0) { result = "G"; } else if (chineseChar.CompareTo("发") >= 0) { result = "F"; } else if (chineseChar.CompareTo("妸") >= 0) { result = "E"; } else if (chineseChar.CompareTo("咑") >= 0) { result = "D"; } else if (chineseChar.CompareTo("嚓") >= 0) { result = "C"; } else if (chineseChar.CompareTo("八") >= 0) { result = "B"; } else if (chineseChar.CompareTo("吖") >= 0) { result = "A"; } else { result = chineseChar.ToUpper(); } return result; } }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。