I have a foreach loop that is supposed to display lines from a txt file when I click a button. Nothing is displaying when I click the button. What am I doing wrong?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
namespace WebApplication1
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Main(object sender, EventArgs e)
{
foreach (string line in File.ReadLines(@"C:\Users\Matt\Desktop\AirportCodes2.txt"))
{
if (line.Contains("Chicago"))
{
Console.WriteLine(line);
}
}
}
}
}
Text file is tab delimited, formatted like this:
Chicago IL ORD O'Hare International