Quantcast
Channel: Getting a string dynamically from strings resources - Stack Overflow
Viewing all articles
Browse latest Browse all 6

Answer by A.Dara for Getting a string dynamically from strings resources

$
0
0

You can write a static method like this:

public static string GetResourceTitle<T>(string key)
{
  ResourceManager rm = new ResourceManager(typeof(T));
  string someString = rm.GetString(key);
  return someString;
}

And call anywhere:

var title=  GetResourceTitle<*YouResourceClass*>(key);

It is useful when you want to have a generic function to get String of any Resource file.


Viewing all articles
Browse latest Browse all 6

Trending Articles



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