0

How do i retrieve a value from a resources file based on the key?

I've got a resources file called GlobalStrings.resx:

enter image description here

I would like to be able to pass in Sheepsmilk and get back Sheep's milk

How do i retrieve a value from a resources file based on the key?

I've attempted like so:

Dim milk = My.Resources.GlobalStrings["Sheepsmilk"]

however, i'm getting the following exception:

'GlobalStrings' is a class type and cannot be used as an expression.

Alex Gordon
  • 57,446
  • 287
  • 670
  • 1,062

1 Answers1

2

You can use the ResourceManager

Dim result = My.Resources.Resource1.ResourceManager.GetString("String1")
Andrew Mortimer
  • 2,380
  • 7
  • 31
  • 33
  • thank you very much, i've asked a follow up to this: https://stackoverflow.com/questions/49022530/how-to-change-the-language-cultureinfo – Alex Gordon Feb 28 '18 at 05:27