I am trying to write a solution that will take input from the user and provide an output after sorting it. i,e. if anyone gives input as 654321 my program will return 123456. Below is the code I have written so far. But it is returning the same without sorting. What mistake I am doing here?
static void Main(string[] args)
{
Console.WriteLine("Enter your number: ");
int input = Convert.ToInt32(Console.ReadLine());
int[] array = new[] {input};
Array.Sort(array);
foreach (var value in array)
{
Console.WriteLine(value);
}
Console.ReadKey();
}
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
Because 123456 is a whole, not List Array.only one element .
Use ListArray. Your code will surely work after that. For help, visit this link : http://knowledgetpoint.com/csharp/