Class1.cs
上传用户:lxycoco
上传日期:2022-07-21
资源大小:38457k
文件大小:1k
- using System;
- using System.Collections;
- using System.Threading;
- using System.Globalization;
- namespace SortDemo
- {
- /// <summary>
- /// Summary description for Class1.
- /// </summary>
- class Class1
- {
- static void DisplayNames(IEnumerable e)
- {
- foreach (string s in e)
- Console.Write(s + " - ");
- Console.WriteLine();
- }
- /// <summary>
- /// The main entry point for the application.
- /// </summary>
- [STAThread]
- static void Main(string[] args)
- {
- string[] names = {"Alabama", "Texas", "Washington",
- "Virginia", "Wisconsin", "Wyoming",
- "Kentucky", "Missouri", "Utah", "Hawaii",
- "Kansas", "Lousiana", "Alaska", "Arizona"};
- Thread.CurrentThread.CurrentCulture =
- new CultureInfo("fi-FI");
- Array.Sort(names);
- Console.WriteLine("nsorted...");
- DisplayNames(names);
- // sort using the invariant culture
- Array.Sort(names, Comparer.DefaultInvariant);
- Console.WriteLine("nsorted with invariant culture...");
- DisplayNames(names);
- }
- }
- }