C#数组类

using System;

namespace ArrayApplication {

   class MyArray {

      static void Main(string[] args) {
         int[] list = { 34, 72, 13, 44, 25, 30, 10 };
         int[] temp = list;
         Console.Write("Original Array: ");

         foreach (int i in list) {
            Console.Write(i + " ");
         }
         Console.WriteLine();

         // reverse the array
         Array.Reverse(temp);
         Console.Write("Reversed Array: ");

         foreach (int i in temp) {
            Console.Write(i + " ");
         }
         Console.WriteLine();

         //sort the array
         Array.Sort(list);
         Console.Write("Sorted Array: ");

         foreach (int i in list) {
            Console.Write(i + " ");
         }
         Console.WriteLine();
         Console.ReadKey();
      }
   }
}

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/265805.html

(0)
上一篇 2022年6月7日
下一篇 2022年6月7日

相关推荐

发表回复

登录后才能评论