My office mate Chad came up with yet an even better option. You need to be using 3.5 and include the System.Linq extension method namespace. It didn't perform quite as well but pretty close. Even more general purpose. Note that the default SequenceEqual method throws an exception when either operator is null so I handled those cases first.
bool Compare<T>(IEnumerable<T> left, IEnumerable<T> right)
{
// handles the same array
// handles both null
if (left == right)
return true;
// fails when either are null
if (left == null || right == null)
return false;
return left.SequenceEqual(right);
}
Remember Me
Powered by: newtelligence dasBlog 2.0.7226.0
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
© Copyright 2008, Your Name Here
E-mail