CSharp - Converting an Array of Strings to Integers and Sorting It

Description

Converting an Array of Strings to Integers and Sorting It

Demo

using System;  
using System.Linq;  
class Program/*from www.  j  av a 2 s.c  om*/
{
    static void Main(string[] args)
    {
        string[] numbers = { "0042", "010", "9", "27" };  
          
        int[] nums = numbers.Select(s => Int32.Parse(s)).OrderBy(s => s).ToArray();  
          
        foreach(int num in nums)  
          Console.WriteLine(num);  
              
    }
}

Result

Related Topic