Binärer Vergleich mit enum und unit...



Hallo,

gegeben sei:

public enum TEST_ENUM : uint
{
COMPARE = 0x1,
}

uint test_val=0x3;

if (( test_val & TEST_ENUM.COMPARE) != 0 )
{
......
}

Die if Anweisung mag der Compiler nicht. Er meldet "Operator '&' cannot be
applied to operands 'uint' an TEST_ENUM.COMPARE. Sehe ich zwar einerseits
ein, weil das enum Objekt kein uint ist aber irgendwie sollte es da trotzdem
einen einfachen Weg geben. Schliesslich ist der enum als ein uint angelegt.

Gruß

Diana



.



Relevant Pages

  • =?Windows-1252?Q?Re:_Bin=E4rer_Vergleich_mit_enum_und_unit...?=
    ... Die if Anweisung mag der Compiler nicht. ... Er meldet "Operator '&' cannot be applied to operands 'uint' an TEST_ENUM.COMPARE. Sehe ich zwar einerseits ein, weil das enum Objekt kein uint ist aber irgendwie sollte es da trotzdem einen einfachen Weg geben. ...
    (microsoft.public.de.german.entwickler.dotnet.csharp)
  • Re: Need help with REDEFINES (I think)....
    ... preclude the compiler optimizing it. ... (a compiler generated subroutine) ... generated subroutine) because it uses a simple compare (or series of ... would be fairly consistent across platforms, but even if I'm wrong and there ...
    (comp.lang.cobol)
  • Re: vm02 preview #4
    ... To compare the interpreter against other interpreters or code ... This case is a nice one of checking compiler and interpreter efficiency. ... If the compiler was a little smart, there are lots of loop invariants to be pulled out of the color calculation, but I don't think the Java compiler is that smart. ... And vm02 has a type-ahead buffer and pre-emptively schedules. ...
    (comp.sys.apple2.programmer)
  • Re: C Comparison Question
    ... unsigned char *a; ... is the compiler allowed to extend ... "integer promotions". ... few machines have hardware that can compare a `double' to an `int' ...
    (comp.lang.c)
  • Re: Javac issues "might be uninitialized" for null test
    ... And any compiler worth its salt would ... Java does not initialize variables (as opposed to class ... Some languages "initialize with garbage" and allow ... compare the non-existent value to `null' is erroneous. ...
    (comp.lang.java.programmer)