Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Static Dictionary Initalization from a static array

$
0
0

I have a static array built from an enum, I would like to set up a static dictionary that uses the values in the array and returns the index

using System.Collections;

using System.Collections.Generic;

using System.Windows.Forms;

namespace somenamespace

{

     static class someclass

     {    

          static Keys[] allKeys = (Keys[])Enum.GetValues(typeof(Keys));
          static Dictionary<Keys, int> allKeysRevDict = new Dictionary<Keys,int>()

          {

               //somecode

              //Keys is the enum value, int is the index into my allKeys array

          }

     }

}


Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>