Convert enum variable to int in C #

2

I have the following code:

enum type = { OPEN = 0, CLOSED, UNDEFINED};
list<int> frequencia = new list<int>(new int[] {0,0,0});

I would like to do the following operation:

type t = enum.OPEN;
frequencia[t]++;

But I can not. Any solution on how to convert the enum variable to int?

    
asked by anonymous 08.05.2014 / 19:04

1 answer

6

Do as follows:

int t = (int)enum.OPEN;
frequencia[t]++;
    
08.05.2014 / 19:06