简体   繁体   English

在ASP.NET C#中以编程方式检索资源值

[英]Retrieve Resource Values Programmatically in asp.net C#

I want to get strings from my App_resource programmatically because I get from the DB a keyword with the name of the string in the app_resource mlbRes. 我想以编程方式从App_resource中获取字符串,因为我从数据库中获得了一个关键字,其中包含app_resource mlbRes中字符串的名称。

I have a stored procedure that indicates what the user should do next, sending a string that corresponds to a string in my app_resources file. 我有一个存储过程,指示用户下一步应该做什么,发送与我的app_resources文件中的字符串相对应的字符串。 I can do it with a switch, but that will only complicate my code. 我可以用一个开关来做,但这只会使我的代码复杂化。

As you can see in the following screenshot, I've tried different approaches, but none worked so far. 正如您在以下屏幕截图中所看到的,我尝试了不同的方法,但是到目前为止,没有一种方法有效。

screenshot 屏幕截图

Can anyone point me out what I'm doing wrong? 谁能指出我做错了什么?

Thanks in advance. 提前致谢。

使用此语法这里mlbRes是您的资源文件名

string value= Resources.mlbRes.ResourceManager.GetString("StringName"); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM