编辑代码

class Anycodes {
    static void Main () {
        System.Console.WriteLine("Anycodes, Hello World of C#!");
        System.Console.WriteLine("");
         int[] array = { 64, 34, 25, 12, 22, 11, 90 };
        
        System.Console.WriteLine("Original Array:");
        DisplayArray(array);
        BubbleSort(array);
        
        System.Console.WriteLine("");
        System.Console.WriteLine("");
        System.Console.WriteLine("Sorted Array:");
        DisplayArray(array);
       // System.Console.ReadKey();
    }
    
    
    
    static void BubbleSort(int[] arr){
        int temp;
        for(int i=0;i<arr.Length-1;i++){
            for(int j=0;j<arr.Length-1-i;j++){
                  if (arr[j] > arr[j + 1])
                {
                    temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }
    }
    
        static void DisplayArray(int[] array)
    {
        foreach (int i in array)
        {
            System.Console.Write(i + " ");
        }
       System. Console.WriteLine();
    }
    
}