I have a variable of type dictionary(string, int32). I want to retrieve the index of a key provided by the user. So if the userInput is “coffee” I want to retrieve the index (0) and if userInput is “tea” I want to retrieve index (1). I want it this way because I want to assign the index to a variable and use it to retrieve a key later in the workflow:
myDictonaryVariable = {{“coffee”, 3}, {“tea”,2}}`
userInput = “coffee”
myIndexVariable = Array.IndexOf(myDictionaryVariable.Keys.ToArray(),userInput)
assigns the index (0) to an int32 variable but is there a better, more direct way of doing this?
myDictionaryVariable.ElementAt(myIndexVariable).Key
returns the key “coffee”
Thank you!