zoukankan      html  css  js  c++  java
  • C#中汉字排序简单示例(拼音/笔划)

    可以按照区域语言修改排序规则。

     class Program
        {
            static void Main(string[] args)
            {
                string[] arr = { "趙(ZHAO)", "錢(QIAN)", "孫(SUN)", "李(LI)", "周(ZHOU)", "吳(WU)", "鄭(ZHENG)", "王(WANG)"};
    
                //发音 LCID:0x00000804
                CultureInfo PronoCi = new CultureInfo(2052);
                //Thread.CurrentThread.CurrentCulture = new CultureInfo("en-us"); 
                Array.Sort(arr);
                Console.WriteLine("按发音排序:");
                for (int i = arr.GetLowerBound(0); i <= arr.GetUpperBound(0); i++)
                    Console.WriteLine("[{0}]:	{1}", i, arr.GetValue(i));
    
                Console.WriteLine();
    
                //笔画数 LCID:0x00020804
                CultureInfo StrokCi = new CultureInfo(133124);
                Thread.CurrentThread.CurrentCulture = StrokCi; 
                Array.Sort(arr);
                Console.WriteLine("按笔划数排序:");
                for (int i = arr.GetLowerBound(0); i <= arr.GetUpperBound(0); i++)
                    Console.WriteLine("[{0}]:	{1}", i, arr.GetValue(i));
    
                Console.WriteLine();
    
                //zh-cn (拼音:简中)
                Thread.CurrentThread.CurrentCulture = new CultureInfo("zh-cn");
                Array.Sort(arr);
                Console.WriteLine("zh-cn:");
                for (int i = arr.GetLowerBound(0); i <= arr.GetUpperBound(0); i++)
                    Console.WriteLine("[{0}]:	{1}", i, arr.GetValue(i));
    
                Console.WriteLine();
    
                //zh-tw (笔划数:繁中)
                Thread.CurrentThread.CurrentCulture = new CultureInfo("zh-tw");
                Array.Sort(arr);
                Console.WriteLine("zh-tw:");
                for (int i = arr.GetLowerBound(0); i <= arr.GetUpperBound(0); i++)
                    Console.WriteLine("[{0}]:	{1}", i, arr.GetValue(i));
    
                Console.ReadKey();
    
            }
        }
  • 相关阅读:
    SQLite数据库如何存储和读取二进制数据
    JS常用代码
    获取内容第一张图片地址的函数
    我对App_Code的理解
    VS2008中Web项目的App_Code目录问题
    jQuery 浮动广告实现代码
    常用的倒计时脚本
    IE8 CSS hack
    精典的网吧常用批处理收集
    ASP.NET中App_Code,App_Data等文件夹的作用
  • 原文地址:https://www.cnblogs.com/51net/p/4550070.html
Copyright © 2011-2022 走看看