Because the code uses !=, not ==; so the first comparison tests whether
(SearchFlags & (int) AttributeSearchFlags.Index) is equal to zero; and
the second tests whether the result of that comparison is false.

-----Original Message-----
From: Moderated discussion of advanced .NET topics.
[mailto:[EMAIL PROTECTED] On Behalf Of Simon Hewitt
Sent: Thursday, 27 February 2003 8:02 PM
To: [EMAIL PROTECTED]
Subject: [ADVANCED-DOTNET] 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

Reply via email to