Prev: Clean Cannot run my application outside VS without previouslydoing a "clean" before rebuild
Next: Reading Text Files w/commas in the data
From: nomad on 5 May 2010 11:39 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.
From: Family Tree Mike on 5 May 2010 13:51
On 5/5/2010 11:39 AM, nomad wrote: > 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? -- Mike |