How to retrieve the element dynamically using List generics

Jan 8 2014 7:08 AM
Here i want to retrieve elements in array during runtime and to sort the integer array and to print the resultant array using List <int> ListInt=new List <int> 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<int> IntList = new List<int> { };
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]);
}
}
}
}
 
 
 

Answers (1)