.resx文件并访问“名称”值 [英] .resx files and accessing the "Name" value

查看:69
本文介绍了.resx文件并访问“名称”值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿All,

我想使用资源文件存储键/值对(resx文件称它们为Name / Value)以查找错误。我希望Key(Name)是错误代码,并且值是消息。


我唯一的问题是我不知道如何获得Key的字符串表示/ Name,因为我想在屏幕上显示代码。


例如在resx文件中:

名称|价值|说明

E001 |我的错误|这是错误1


代码:

Resources.ERROR1会给我回复我的错误,但我也希望得到E001。回来了。这有可能吗?


谢谢!

Hey All,
I want to use a resource file to store key/value pairs (resx file calls them Name/Value) for errors. I want the Key(Name) to be the error code, and the value to be the message.

My only issue is I do not know how to get a string representation of the Key/Name, as I want to display the code on screen as well.

For instance in the resx file:
Name | Value | Description
E001 | My Error | This is error 1

In Code:
Resources.ERROR1 will return me me "My Error", but I also want to get "E001" back as well. Is this possible in any way?

Thanks!

推荐答案

为了使用密钥E001访问资源;你必须知道E001。是你的关键...


为什么在首先访问资源所需的信息时,需要将其从资源文件中拉出来?


现在,我注意到您正在使用密钥E001访问资源。当Resources.ERROR1发生时。


我真的不清楚你的问题是什么,但考虑而不是使用ERROR1作为您的关键值而不是E001检索文本...然后在另一个资源文件中使用ERROR1和ERROR1。作为检索文本E001的关键。


-Frinny
In order to access the resource with the Key "E001" you have to know that "E001" is your key...

Why do you need to pull this out of the resource file when it is the information you need in order to access the resource in the first place?

Now, I''m noting that you are accessing the resource with the key "E001" when Resources.ERROR1 has occurred.

I really am not clear on what your problem is but consider instead of using "ERROR1" as your key value instead of "E001" to retrieve the text...then in another resource file use "ERROR1" as the key to retrieve the text "E001".

-Frinny


您可以模仿资源管理器的工作。

这里是来自设计师代码的snippit:
You could mimic what the resource manager does.
Here''s a snippit from the designer code:
展开 | 选择 | Wrap | 行号


是的,这是我的挑战。 />

我有一个包含错误消息的资源文件。

E001 - 错误1

E002 - 错误2

等等


现在当我去显示错误时,我想在弹出标题栏的消息中显示错误代码,消息框中的消息。


所以我知道我想要显示E001,所以我只想说一下Resources.E001,这给了我错误1。 />

现在,当我想在标题中输入错误代码E001时,我不想硬编码,我只想翻译密钥/名称。这有意义吗?


所以在我想要的MessageBox中:
Yeah, here is my challenge.

I have a resource file with error messages.
E001 - Error 1
E002 - Error 2
etc, etc

Now when I go to display the error, I want to display the error code in a message pop up title bar, and the message in the message box itself.

So I know I want to display E001, so I would simply say Resources.E001 and that gives me "Error 1".

Now when I want to put the error code E001 in the title, I don''t want to hardcode that, I want to just translate the key/Name. Does that makes sense?

So in a MessageBox I want:
< span class =codeLinkonclick =Blur(this,this.parentNode.parentNode,getChildren(this),true);>展开 | 选择 | Wrap | 行号


这篇关于.resx文件并访问“名称”值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆