zoukankan      html  css  js  c++  java
  • 转换汉子首字母类 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;
            }
        } 
  • 相关阅读:
    《那些年,我们拿下FPGA》做笔记
    三种初始化
    hdu4417 Super Mario 树阵离线/划分树
    【设计模式】文章摘要 查找联系人控件
    STL set
    阐述 QUEST CENTRAL FOR DB2 八罪
    使用线程执行堆栈StackTraceElement设计Android日志模块
    苹果iOS苹果公司的手机用户都有权索赔
    Android 4.4 沉浸式透明状态栏与导航栏
    常见的几种RuntimeException
  • 原文地址:https://www.cnblogs.com/dragon-L/p/3680616.html
Copyright © 2011-2022 走看看