Comparing Byte Arrays in C# and more specifically using the .NET 3.5 Framework

I was looking for a simple way of comparing two byte arrays and it is not as 123 as you may think as methods which you may assume would return true, DO NOT.  I found a solution that does exactly what I need and is part of the framework, and I found it on the link below.  It also contains examples at the beginning which may surprise you:

http://blog.tatham.oddie.com.au/2008/07/01/comparing-byte-arrays-in-c-or-at-least-trying-to/

To summarize the method I am speaking of is the following:

public static bool SequenceEqual<TSource>(this System.Collections.Generic.IEnumerable<TSource> first, System.Collections.Generic.IEnumerable<TSource> second)
    Member of System.Linq.Enumerable

Summary:
Determines whether two sequences are equal by comparing the elements by using the default equality comparer for their type.

And it was from a comment may by a guy calling himself RichB in the blog post above.  Great find!

Cheers,

Andrew

Published Friday, February 20, 2009 11:17 AM by REA_ANDREW
Filed under:

Comments

No Comments

Leave a Comment

(required) 
(required) 
(optional)
(required)