转换汉子首字母类 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;
        }
    } 

 

posted @ 2014-04-22 15:24  dragon.net  阅读(256)  评论(0编辑  收藏  举报