I have two foreach loops, each of which loops through a text file, and gets the value of all of the values of the first two columns only (there are more than two columns in the text file, delimited by "|") and puts it in a string. I would like to compare the result of these foreach loops (the values that are output by the Response.Write
statements) to see if the strings are equivalent or not. Any thoughts/suggestions appreciated.
protected void Page_Load(object sender, EventArgs e)
{
string textFile1 = @"C:\Test\Test1.txt";
string textFile2 = @"C:\Test\Test2.txt";
string[] textFile1Lines = System.IO.File.ReadAllLines(textFile1);
string[] textFile2Lines = System.IO.File.ReadAllLines(textFile2);
char[] delimiterChars = { '|' };
foreach (string line in textFile1Lines)
{
string[] words = line.Split(delimiterChars);
string column1And2 = words[0] + words[1];
Response.Write(column1And2);
}
foreach (string line in textFile2Lines)
{
string[] words = line.Split(delimiterChars);
string column1And2 = words[0] + words[1];
Response.Write(column1And2);
}
}