/// <summary>  
        /// 获取中文字符串的首字母  
        /// </summary>  
        /// <param name="strText"></param>  
        /// <returns></returns>  
        public static string GetChineseSpell(string strText)
        {
            int len = strText.Length;
            string myStr = "";
            for (int i = ; i < len; i++)
            {
                myStr += getSpell(strText.Substring(i, ));
            }
            return myStr;
        }         /// <summary>  
        /// 获取单个中文的首字母  
        /// </summary>  
        /// <param name="cnChar"></param>  
        /// <returns></returns>  
        private static string getSpell(string cnChar)
        {
            byte[] arrCN = Encoding.Default.GetBytes(cnChar);
            if (arrCN.Length > )
            {
                int area = (short)arrCN[];
                int pos = (short)arrCN[];
                int code = (area << ) + pos;
                int[] areacode = { , , , , , , , , , , , , , , , , , , , , , , , , ,  };                 for (int i = ; i < ; i++)
                {
                    int max = ;
                    if (i != )
                    {
                        max = areacode[i + ];
                    }
                    if (areacode[i] <= code && code < max)
                    {
                        return Encoding.Default.GetString(new byte[] { (byte)( + i) });
                    }
                }
                return "*";
            }
            else return cnChar;
        }  

c#提出中文首字母的更多相关文章

  1. php按照中文首字母排序

    1> 网络上很多php的工具类可以将汉字转为拼音: 2> 将拼音进行排序即可 另一种则是类似mysql转码方式: 1 foreach ($array as $key=>$value) ...

  2. mysql排序的中文首字母排序和自定义排序

    select * FROM organ_new where city_code = 'SZ0755' and organ_type = 'H' and state = '1' ORDER BY FIE ...

  3. PHP获取中文首字母的函数

    PHP获取中文首字母的函数 <?php header("Content-type: text/html; charset=utf-8"); function getFirst ...

  4. Java获取中文拼音、中文首字母缩写和中文首字母

    获取中文拼音(如:广东省 -->guangdongsheng) /** * 得到中文全拼 * @param src 需要转化的中文字符串 * @return */ public static S ...

  5. oc中文首字母排序

    oc中文首字母排序 NSArray *arr2=@[@"小雨",@"安安",@"小风",@"荣荣",@"张涛& ...

  6. js中文首字母数组排序

    js中文首字母数组排序 数组的排序js算法: var Pinyin = (function() { var Pinyin = function(ops) { this.initialize(ops); ...

  7. Java中实现对集合中对象按中文首字母排序

    有一个person对象如下: public class Person { private String id;private String nam; } 一个list集合如下: List<Emp ...

  8. php里获取第一个中文首字母并排序

    需求里结算首页需要按门店的首字母A-Z排序.我的数据结构原本是这样的: Array ( [0] => Array ( [sid] => 2885842 [recetcstoredpay] ...

  9. 关于java中实现在oracle数据库中实现对中文首字母进行排序的解决方案

    首先介绍Oracle 9i新增加的一个系统自带的排序函数 1.按首字母排序 在oracle9i中新增了按照拼音.部首.笔画排序功能.设置NLS_SORT值     SCHINESE_RADICAL_M ...

随机推荐

  1. tyvj1039忠诚2

    描述 Description 老管家是一个聪明能干的人.他为财主工作了整整10年,财主为了让自已账目更加清楚.要求管家每天记k次账,由于管家聪明能干,因而管家总是让财主十分满意.但是由于一些人的挑拨, ...

  2. .net常考面试题

    1. 简述 private. protected. public. internal 修饰符的访问权限. 答 . private : 私有成员, 在类的内部才可以访问. protected : 保护成 ...

  3. Java Access Levels(访问控制)

    Access Levels Modifier Class Package Subclass World public Y Y Y Y protected Y Y Y N no modifier Y Y ...

  4. hdu 5159 Card (期望)

    Problem Description There are x cards on the desk, they are numbered from 1 to x. The score of the c ...

  5. hdfs经常使用命令

    hadoop hdfs经常使用命令 hadoop fs -ls /user/deploy/recsys/workspace/ouyangyewei 查看ouyangyewei文件夹文件 hadoop ...

  6. App版本更新时对SQLite数据库升级或者降级遇到的问题

    SQLite是Android内置的一个很小的关系型数据库.SQLiteOpenHelper是一个用来辅助管理数据库创建和版本升级问题的抽象类.我们可以继承这个抽象类,实现它的一些方法来对数据库进行自定 ...

  7. Impala 源码分析-FE

    By yhluo 2015年7月29日 Impala 3 Comments Impala 源代码目录结构 SQL 解析 Impala 的 SQL 解析与执行计划生成部分是由 impala-fronte ...

  8. Mysql存储引擎概念特点介绍及不同业务场景选用依据

    目录 MySQL引擎概述 1 MySAM引擎介绍 2 什么是InnoDB引擎? 3 生产环境中如何批量更改MySQL引擎 4 有关MySQL引擎常见企业面试题 MySQL引擎概述 Mysql表存储结构 ...

  9. 使用堆栈结构进行字符串表达式("7*2-5*3-3+6/3")的计算

    问题: 给定字符串String str = "7*2-5*3-3+6/3", 求出字符串里面表达式的结果? 像javascript有自带的eval()方法,可以直接计算.但java ...

  10. JS高级程序设计学习笔记之Date类型

    日期对象的创建:var now =new Date(),不传递参数时,对象自动获取当前时间.(若要创建特定日期与时间的对象,必须传入该日期距离1970/1/1零点的毫秒数). Date.parse() ...