i wrote a simple code my program need two input one is name and 2th is number(phone number). and i wrote one section to find contacts. when user enter 1 he should add a name and phone number then user can enter 1or 2(1 for add contact and 2 for search) when user enter 1 again all of old date well delete and i don't want this please help.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace project_01
{
class Program
{
static void Main(string[] args)
{
string[] names = new string[5];
string[] phonenumb = new string[5];
bool itsTrue;
//int counter;
string help = @"enter 1 for add contact.
enter 2 for exit.0
enter 3 for search";
Console.WriteLine(help);
while (true)
{
Console.Write("=>");
int input = Convert.ToInt32(Console.ReadLine());
if (input == 1)
{
for (int i = 0; i < names.Length;)
{
Console.Write("name : ");
names[i] = Console.ReadLine();
Console.Write("number : ");
phonenumb[i] = Console.ReadLine();
i++;
break;
}
}
else if (input == 2)
{
Console.Write("enter y for exir and n to stay: ");
string exit = Console.ReadLine().ToUpper();
if (exit == "Y")
{
break;
}
else if (exit == "N")
{
continue;
}
}
else if (input == 3)
{
Console.Write("enter the name: ");
string search = Console.ReadLine();
itsTrue = false;
for (int j = 0; j < names.Length; j++)
{
if (search == names[j])
{
Console.WriteLine("name: {0}", names[j]);
Console.WriteLine("number:{0}", phonenumb[j]);
itsTrue = true;
break;
}
}
if (!itsTrue)
{
Console.WriteLine("content not found.");
}
}
}
}
}
}