Arrays Search – Code

[code language=”csharp”] using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ArraysSearches
{
class Program
{
static void Main(string[] args)
{
int[] idNumbers = { 122, 167, 204, 219, 345 };
int x;
string entryString;
int entryId;
Write("Enter an Employee ID ");
entryString = ReadLine();
entryId = Convert.ToInt32(entryString);
x = Array.BinarySearch(idNumbers, entryId);
if (x < 0)
WriteLine("ID {0} not found", entryId);
else
WriteLine("ID {0} found at position {1} ",
entryId, x);

//////////////////////////////////////// sort

//string[] names = {"Olive", "Patty", "Richard", "Ned", "Mindy"};
//int x;
//Array.Sort(names);
//for (x = 0; x < names.Length; ++x)
// WriteLine(names[x]);
}
}
}
[/code]