I want to make an enum for possible grades. This is a working example:
public enum Grade
{
    A, B, C, D, E, F
}
However, I want the grades to be integers, like
public enum Grade
{
    1, 2, 3, 4, 5
}
Why does the first one work but not the second? How can I make a similar variable that can only take values from 1-5 (and is nullable)?
You should specify Grade like this.
public enum Grade
{
    A = 1,
    B,
    C,
    D,
    E,
    F
}
B, C and so on will take next value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With