What's hot ? (and I mean really ...) - scroll down for more
1).  Code Templating - advanced usage of delegates & generics: my slides & demos are available for download! CodeProject article is also available.

2).  My series "TDD in the eyes of a simpleminded" is in progress(including code!): preface, part1, part2, Q&A 1, Manual Stub .vs. Mock Stub

3).  TDD Workshop: SeeCompass v0.1 and v0.2 are out.
# Tuesday, January 16, 2007

I have to following code:

BitArray arr1 = new BitArray(200);
BitArray arr2 = new BitArray(200);

arr1[2] = true;
arr2[2] = true;

if (arr1.And(arr2) == arr2)
   Console.WriteLine("good");
else 
   Console.WriteLine("bad");

It returns "bad" for some unknown reason.
My guess is that Equals implemented a reference comparison and not bitwise comparison.
It seems like a strange behavior as BitArray is classic for bitwise operations on it.

Am I missing something?

update: I've refactored Microsoft orginal BitArray and named it BitArray2. You can find it here.

Tuesday, January 16, 2007 7:55:15 PM (Jerusalem Standard Time, UTC+02:00)
No unknown reason.
BitArray is a class that doesn't override Equals or has overloading on ==
Therefor, it is using the default for classes, which is reference equality.
Friday, January 19, 2007 2:07:26 PM (Jerusalem Standard Time, UTC+02:00)
Yep, that's what I thought. That's why I did BitArray2:
http://www.lnbogen.com/UsableBitArrayTake2.aspx
Comments are closed.