Here i want to retrieve elements in array during runtime and to sort the integer array and to print the resultant array using List ListInt=new List ListInt{} generics. Please help me to this sample code given below.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Prime2
{
class RuntimeSortOfNumbers
{
static void Main(string[] args)
{
int size;
Console.WriteLine("Enter The Size of List ");
size = int.Parse(Console.ReadLine());
Console.WriteLine("Enter The Elements in List to Sort");
List IntList = new List { };
for (int i = 0; i < size; i++)
{
IntList = int.Parse(Console.ReadLine());
}
IntList.Sort();
Console.WriteLine("Sorted List");
for (int i = 0; i < size; i++)
{
Console.WriteLine(IntList[i]);
}
}
}
}
1 Reply
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Jan 8, 2014, 9:06 AM