码迷,mamicode.com
首页 > 其他好文 > 详细

ToUpperInvariant and Array.Sort

时间:2015-01-23 16:09:53      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:

           string[] words = { "Tuesday", "Sal?", "Вторник", "Mardi", 
                         "Τρ?τη", "Martes", "??? ?????", 
                         "????????", "?????????" };
                      StreamWriter sw = new StreamWriter(@".\output.txt");

                      // Display array in unsorted order.
                      foreach (string word in words)
                            sw.WriteLine(word);

                      sw.WriteLine();

                      // Create parallel array of words by calling ToUpperInvariant.
                      string[] upperWords = new string[words.Length];
                      for (int ctr = words.GetLowerBound(0); ctr <= words.GetUpperBound(0); ctr++)
                            upperWords[ctr] = words[ctr].ToUpperInvariant();

                      // Sort the words array based on the order of upperWords.
                      Array.Sort(upperWords, words, StringComparer.InvariantCulture);

                      // Display the sorted array.
                      foreach (string word in words)
                            sw.WriteLine(word);

                      sw.Close();

 

ToUpperInvariant and Array.Sort

标签:

原文地址:http://www.cnblogs.com/yipeng-yu/p/4244213.html

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