W3School TIY Editor

  • W3School 在线教程
  • 改变方向
  • 暗黑模式
​x
 
using System;
​
namespace MyApplication
{
  class Program
  {
    static void Main(string[] args)
    {
      // 对字符串数组进行排序
      string[] cars = {"Volvo", "BMW", "Ford", "Tesla"};
      Array.Sort(cars);
      foreach (string i in cars)
      {
        Console.WriteLine(i);
      }    
      
      // 对整数数组进行排序
      int[] myNumbers = {5, 1, 8, 9};
      Array.Sort(myNumbers);
      foreach (int i in myNumbers)
      {
        Console.WriteLine(i);
      }
    }
  }
}