the operator '==' can not be applied to operands of type int

1

I have this error message when I call or create a enum , this is the enumerator

public enum mexTipAutent :int
{
 mvxBD = 2,
 mvxWA = 4,
 mvxAPP = 8,
}

and this is the call where the error marks me

if (pnTipAutent == clsBaseDatos.mexTipAutent.mvxBD)
{
}

thanks in advance.

Greetings

    
asked by alfredo.avmb 15.07.2017 в 20:35
source

1 answer

4

You can not compare a enum with a int , you must compare its underlying type.

Extracted from the official documentation, reference page of enum :

  

The underlying type specifies the amount of storage allocated to each enumerator. However, you need an explicit conversion to convert an enum type to an integer type

That is, you must use:

if( pnTipAutent == (int)clsBaseDatos.mexTipAutent.mvxBD )

Greetings

    
answered by 15.07.2017 / 20:51
source