C#の漢字並べ替えの簡単な例(ピンイン/ストローク)
6317 ワード
ゾーン言語に従ってソートルールを変更できます.
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();
}
}