Skip to content

Instantly share code, notes, and snippets.

@jarlrasm
Last active September 30, 2016 08:53
Show Gist options
  • Save jarlrasm/16b3903e9b56c198aaec0957bc54017a to your computer and use it in GitHub Desktop.
Save jarlrasm/16b3903e9b56c198aaec0957bc54017a to your computer and use it in GitHub Desktop.
C# Find string mismatch(Protip: it is \r\n).There sure must be some easier way to do this.
var mismatch = text1.Zip(text2, (x, y) => new { x, y })
.Aggregate(new { total = "", mismatch = "" },
(current, t) => new
{
total = current.total + new string(new char[] { t.x }),
mismatch =
(t.x == t.y) ? current.mismatch : current.total,
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment