How to compare two byte arrays?

V

Vadym Stetsyak

Hello, Ole!

O> How do I compare two byte arrays in a if statement?

You have to loop through array comparing every item.

Smth like

bool IsEqual(byte[] arr1, byte[] arr2)
{
if ( arr1 == null || arr2 == null )
return false;

if ( arr1.Length != arr2.Length )
return false;

//and here is the check loop
for(int i = 0; i < arr1.Length; i++ )
{
if ( arr1 != arr2 )
return false;
}
return true;
}

--
Regards, Vadym Stetsyak
www: http://vadmyst.blogspot.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top