class Program { public static bool findInText(int textSearchValue, string filePath) //Функция считывания файла построчно, приведения строки к числу и сравнение с искомым значением { try { using (StreamReader sr = new StreamReader(filePath)) { string line; while ((line = sr.ReadLine()) != null) { int a = Int32.Parse(line); if (a == textSearchValue) return true; } return false; } } catch (Exception e) { Console.WriteLine("Файл не может быть прочитан"); Console.WriteLine(e.Message); return false; } } static void Main(string[] args) { string myFile = "E:\\test.txt"; Console.WriteLine(findInText(18, myFile)); Console.ReadKey(); } }