0

I have an IEnumerable which contains differences of two files. I want to show these differences in a message box.

I tried to convert it with the toArray() method and with the toString() method.

IEnumerable<String> inFirstNotInSecond = file1Lines.Except(file2Lines);
IEnumerable<String> inSecondNotInFirst = file2Lines.Except(file1Lines);

//i also tried this commented line below
//string Diff = new string(inFirstNotInSecond.Take(50).ToArray());

string Diff = inFirstNotInSecond.ToArray().ToString();
string Diff2 = inSecondNotInFirst.ToString();
MessageBox.Show("Difference:" + Diff + Diff2);

When I run the code I don't get the expected differences but rather this: "System.String[]System.Linq.Enumerable+d__73`1[System.String]"

1 Answers1

1
List<string> myStrings = new List<string>()
{
    "aaa",
    "bbb",
    "ccc",
};

Console.WriteLine(String.Join(";", myStrings));
// Result:
// aaa;bbb;ccc

Console.WriteLine(String.Join("\n", myStrings));
// Result:
// aaa
// bbb
// ccc
kara
  • 3,205
  • 4
  • 20
  • 34