2 つの foreach ループがあり、それぞれがテキスト ファイルをループし、最初の 2 列のみのすべての値の値を取得し (テキスト ファイルには "|" で区切られた 2 つ以上の列があります)、それを文字列にします。これらの foreach ループの結果 (ステートメントによって出力される値) を比較してResponse.Write
、文字列が等しいかどうかを確認したいと思います。任意の考え/提案をいただければ幸いです。
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);
}
}