/// <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. socket pro

    /etc/exports/tmp目录共享为任何人可以共享并可以进行读写操作 /tmp *(rw,no_root_squash) /home/test 192.168.1.*(rw) *(ro) /et ...

  2. EL表达式使用之类switch语句

    http://blacksonny.iteye.com/admin/blogs/1879878

  3. banner背景通栏

     background: #76CEF6 url("../images/bg.jpg") repeat-x 0 0;  -webkit-background-size: 100%; ...

  4. 关于背景透明,文字不透明的最佳方法,兼容IE

    以背景黑色,透明度0.5举例 非IE:background:rgba(0,0,0,0.5); IE:filter:progid:DXImageTransform.Microsoft.gradient( ...

  5. Activity中的startActivityResult,setResult,finish,onActivityResult的关系

    一:首先图示: 二:代码: 1:方法selectName public void selectName(View view){ Intent intent = new Intent(this,Name ...

  6. [RxJS] Handling a Complete Stream with Reduce

    When a stream has completed, you often need to evaluate everything that has happened while the strea ...

  7. Java中日期时间API小结

    Java中为处理日期和时间提供了大量的API,确实有把一件简单的事情搞复杂的嫌疑,各种类:Date Time Timestamp Calendar...,但是如果能够看到时间处理的本质就可以轻松hol ...

  8. 《第一行代码》学习笔记21-Git

    Git(1) 1.Git是一个开源的分布式版本控制工具,其开发者是Linux操作系统的作者Linus Torvalds. 2.仓库(Repository)是用于保存版本管理所需要信息的地方,所有本地提 ...

  9. centos打开3306端口

    centos默认是关闭了3306端口的,外网通过3306端口不能访问数据库,这时需呀打开3306端口1.打开端口: /sbin/iptables -I INPUT -p tcp --dport 330 ...

  10. 1、shell 简介

    Shell 本身是一个用C语言编写的程序,它是用户使用Unix/Linux的桥 梁,用户的大部分工作都是通过Shell完成的.Shell既是一种命令语言,又是一种程序设计语言.作为命令语言,它交互式地 ...