码迷,mamicode.com
首页 > 编程语言 > 详细

C#中汉字排序简单示例(拼音/笔划)

时间:2015-06-03 21:08:55      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:

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

 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}]:\t{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}]:\t{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}]:\t{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}]:\t{1}", i, arr.GetValue(i));

            Console.ReadKey();

        }
    }

 

C#中汉字排序简单示例(拼音/笔划)

标签:

原文地址:http://www.cnblogs.com/zfanlong1314/p/4550070.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!