Simon, >why is the comparison to 0 done twice?
Well, you should think of the second 0 as the constant for false. So an expression x != 0 gets deduced like this: x != 0 !(x == 0) (x == 0) == false (x == 0) == 0 x == 0 == 0 You could also reason the other way around: what if there was only one comparison, like you are implying to be what you were expecting? Wouldn't you then just simply check for equality? HTH, Stefan >-----Original Message----- >From: [EMAIL PROTECTED] >[mailto:[EMAIL PROTECTED] On Behalf >Of Simon Hewitt >Sent: Thursday, February 27, 2003 11:02 AM >To: [EMAIL PROTECTED] >Subject: Compilation question.... > > >Given this source code > >C# source: > public bool IsIndexed { > get { return (SearchFlags & (int) >AttributeSearchFlags.Index) != 0; } > } > > >why is the comparison to 0 done twice? > > > >Anakrino decompilation: >public bool get_IsIndexed() { > return this.SearchFlags & 1 == 0 == 0; >} > > >ILDASM decompilation: >{ > // Code size 15 (0xf) > .maxstack 2 > IL_0000: ldarg.0 > IL_0001: call instance int32 >SimmoTech.ActiveDirectory.ADAttributeSchema::get_SearchFlags() > IL_0006: ldc.i4.1 > IL_0007: and > IL_0008: ldc.i4.0 > IL_0009: ceq > IL_000b: ldc.i4.0 > IL_000c: ceq > IL_000e: ret >} // end of method ADAttributeSchema::get_IsIndexed >