class Employee
{
public int id { get; set; }
public string name { get; set; }
}
--------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication30
{
class Program
{
static void Main(string[] args)
{
List<Employee> li = new List<Employee>();
Console.WriteLine("How many records you want to add in list:");
int n = int.Parse(Console.ReadLine());
for (int i = 0; i < n; i++)
{
Console.ForegroundColor = System.ConsoleColor.Yellow;
Console.WriteLine("Enter the name: ");
Employee emp = new Employee();
emp.name = Console.ReadLine();
emp.id = i + 1;
li.Add(emp);
Console.ForegroundColor = System.ConsoleColor.Green;
Console.WriteLine("1 RECORDS SUCCESSFULLY INSERTED IN LIST.......");
Console.WriteLine("PRESS ANY KEY.....");
Console.ReadLine();
Console.Clear();
}
Console.WriteLine("PRESS ANY KEY.....");
Console.ReadLine();
foreach (var item in li)
{
Console.ForegroundColor = System.ConsoleColor.Red;
Console.WriteLine("-----------------------------------------------");
Console.ForegroundColor = System.ConsoleColor.Cyan;
Console.WriteLine("ID: "+item.id);
Console.WriteLine("Name: " + item.name);
Console.ForegroundColor = System.ConsoleColor.Red;
Console.WriteLine("-----------------------------------------------");
}
Console.ReadLine();
}
}
}