Compare iterated types (IEnumerables and their kin) by values (to check for equality)


/ Published in: C#
Save to your folder(s)

When I'm running unit tests, I find it very annoying to have to check equality within loops when I've got two collections of data. I know of no built-in way (let me know if there is one) [Edit: [CollectionAssert](http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.unittesting.collectionassert.aspx) does it. Sometimes you need to turn your IEnumerables into arrays, though, using .ToArray()] to compare two collections' values (such as an array of bytes compared to a list of bytes), so I made this extension method to do it.

URL: http://stackoverflow.com/questions/630263/c-compare-contents-of-two-ienumerables

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.