.net - .net - how to read resources file by key? - answerstu - answerstu.com answerstu

.net - how to read resources file by key?

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.

1 Answer

  1. Lance- Reply

    2019-11-13

    You can use the ResourceManager

    Dim result = My.Resources.Resource1.ResourceManager.GetString("String1")
    

Leave a Reply

Your email address will not be published. Required fields are marked *

You can use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>