calling Enum for value

Asked

Viewed 79 times

1

I created an Enum:

 public enum EnumTipoBoleto
    {
        VazioErro=0,
        ConfigInicial = 1,
        Mensalidade = 2,
        Outros =3,
        DifMensal =4
    }

Now in some places I have the number and want to convert to Enum

var variavel = 2;
var valorEnum = EnumTipoBoleto[variavel]; //Como faço?
'EnumTipoBoleto' is a type, which is not valid in the given context

1 answer

1


Try to cast a cast

For example:

var variavel = 2;
var valorEnum = (EnumTipoBoleto)variavel;
  • uhahuahua was just that.. Aff that I falter my.. rs

Browser other questions tagged

You are not signed in. Login or sign up in order to post.