Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Collections;
namespace LinearSearch
{
class Program
{
static void Main(string[] args)
{
string toFind = "";
Console.WriteLine("Linear Search");
Console.Write("Enter the item to find: ");
toFind = Convert.ToString(Console.Read());
Console.WriteLine(toFind);
StreamReader sr = new StreamReader("Cars.txt");
ArrayList al = new ArrayList();
String lines = String.Empty;
while ((lines = sr.ReadLine()) != null)
{
lines = sr.ReadLine();
al.Add(lines);
}
foreach (string line in al)
{
if(line == toFind)
{
Console.WriteLine("The item of {0} was found", line);
break;
}
}
sr.Close();
Console.WriteLine("Unable to find the item");
Console.ReadLine();
}
}
}
Comment