Tuesday, 27 August 2013

checking equality for two byte arrays

checking equality for two byte arrays

i am checking the equality of two byte arrays and i wanted some help
because what i have returns false even though the arrays should be equal.
within my debug i could see both of a1 and b1 are equal but it is not
going inside the while loop to increment i.
public bool Equality(byte[] a1, byte[] b1)
{
int i;
bool bEqual ;
if (a1.Length == b1.Length)
{
i = 0;
while ((i < a1.Length) && (a1[i]==b1[i]))
{
i++ ;
}
if (i == a1.Length)
{
bEqual = true;
}
}
return bEqual ;
}
this always returns false: (a1[i]==b1[i])

No comments:

Post a Comment