8
I have an Enum (enumeration) calling Notas
and need to obtain the integer corresponding to one of its constants.
public enum Nota
{
Otimo = 5,
MuitoBom = 4,
Bom = 3,
Regular = 2,
Ruim = 1,
Insuficiente = 0
}
I tried the following, but I was unsuccessful:
Aluno aluno = new Aluno();
aluno.Nota = Nota.MuitoBom;
The estate Conceito
is of the whole type and yet I cannot take the whole value of the constant Nota.MuitoBom
, because the compiler says you can’t implicitly convert the type Nota
for int
.
Can you add the exact error message reported by the compiler? (And I think you got confused by including the answer in the question. The codes are the same)
– Guilherme Bernal