Help with multi-dimensional arrays

N

nomad

Hi,

I have a multi-dimensional array which consists of 29 rows of two
values which make up an enum's values i.e. {10, "Test"}, {20, "Test"}
etc. I then have two other arrays, made up of an enums Enum.GetNames
& Enum.GetValues. I want to be able to create another multi-
dimensional array which is made up of the arrays of Enum.GetValues &
Enum.GetNames, so I can then do a comparison between my multi-
dimensional array and the enums. This is used in a unit test to make
sure no enum values are changed in future.

Appreciate any help on this.
 
F

Family Tree Mike

Hi,

I have a multi-dimensional array which consists of 29 rows of two
values which make up an enum's values i.e. {10, "Test"}, {20, "Test"}
etc. I then have two other arrays, made up of an enums Enum.GetNames
& Enum.GetValues. I want to be able to create another multi-
dimensional array which is made up of the arrays of Enum.GetValues&
Enum.GetNames, so I can then do a comparison between my multi-
dimensional array and the enums. This is used in a unit test to make
sure no enum values are changed in future.

Appreciate any help on this.

Assuming your enum is named enumABC:

int n = Enum.GetValues(typeof(enumABC)).Length;
object[,] A = new object[n, 2];
int idx = 0;
foreach (enumABC e in Enum.GetValues(typeof(enumABC)))
{
A[idx, 0] = (int)e;
A[idx, 1] = e.ToString();
++idx;
}


Why would your enum change out of your control?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top