using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication29
{
class Program
{
static void Main(string[] args)
{
string t;
List<string> li = new List<string>();
Console.WriteLine("How many names you want to add in list: ");
int n = int.Parse(Console.ReadLine());
for (int i = 0; i < n; i++)
{
Console.WriteLine("Enter the name: ");
t = Console.ReadLine();
li.Add(t);
Console.ForegroundColor = System.ConsoleColor.Green;
Console.WriteLine("Data successfully added in list.....");
Console.ReadLine();
Console.Clear();
Console.ForegroundColor = System.ConsoleColor.White;
}
Console.ForegroundColor = System.ConsoleColor.Green;
Console.WriteLine("Press any key to print all names");
Console.ReadLine();
foreach (var item in li)
{
Console.ForegroundColor = System.ConsoleColor.Yellow;
Console.WriteLine("name: "+item);
}
Console.ReadLine();
}
}
}
No comments:
Post a Comment