0

This is my code. I am a beginner in c# and this is for school. I have no idea why the output is just system. Int32 5 times?!?

using System;

class Program
{
    public static void Main(string[] args)
    {
        int[] arr = {6, 2, 8, 3, 1};
        Console.WriteLine(arr);
        int l = arr.Length;
        for (int i = 1; i < l; i++)
        {
            int key = arr[i];
            int j = i - 1;
            while (j >= 0 && arr[j] > key)
            {
                arr[j + 1] = arr[j];
                j--;
            }

            Console.WriteLine(arr);
        }
    }
}

I wanted my code to be a simple insertion sort. Ordering the numbers in ascending order

Jamiec
  • 133,658
  • 13
  • 134
  • 193

0 Answers0