How to sort array of integers in C#

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] arr = { 4, 6, 2, 0, 5, 3, 1 };

            Array.Sort(arr);

            foreach (int n in arr)
                Console.Write(n + " ");
        }
    }
}


/*
run:
    
0 1 2 3 4 5 6

*/

 



answered Feb 13, 2017 by avibootz
...