using System;
using System.Collections;
using System.IO;
namespace Contains
{
class Program
{
static void Main(string[] args)
{
StreamReader myfile = File.OpenText("text.txt");
try
{
ArrayList list = new ArrayList();
string line;
do
{
line = myfile.ReadLine();
if (line != null)
list.Add(line);
}
while (line != null);
myfile.Close();
string sentence;
bool exit = false;
do
{
Console.Write("Enter word or sentence: ");
sentence = Console.ReadLine();
if (sentence == "")
exit = true;
else
{
for (int i = 0; i < list.Count; i++)
{
string sentenceList = (string)list[i];
if (sentenceList.Contains(sentence))
{
Console.WriteLine(sentenceList);
}
}
}
}
while (!exit);
}
catch (Exception e)
{
Console.WriteLine("Error, " + e.Message);
}
}
}
}