是.NET资源文件中的字符串实习? [英] Are .NET resource file strings interned?

查看:138
本文介绍了是.NET资源文件中的字符串实习?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用.resx文件来存储固定的字符串值(绑定到控件在.aspx页面上),在这些字符串拘留?

When I use a .resx file to store fixed string values (to be bound to controls on an .aspx page), are these strings interned?

我presume编译器读取XML文件中的字符串,并将它们替换为在code文字,因此他们成为实习。

I presume the compiler reads in the strings from the XML file and replaces them as literals in the code, and therefore they become interned.

这是正确的?

推荐答案

@ MARC-好点。我试了一下,答案是'不',他们没有实习,至少在GetGlobalResourceObject()方法,所以我想相同的本地资源。

@Marc- good point. I tried it and the answer is, 'no', they're not interned, at least for the GetGlobalResourceObject() method, so I assume the same for local resources.

所以,现在我不知道为什么。资源,目的是要常量和他们经常使用的,所以我会认为实习是有道理的。

So, now I wonder why. Resources are meant to be constants and they are frequently used, so I would have thought interning makes sense.

显然,他们没有文字,因为他们必须从XML资源文件加载,但不应该的问题,应该吗?

Obviously, they're not literals, as they must be loaded from the XML resources file, but that shouldn't matter, should it?

这篇关于是.NET资源文件中的字符串实习?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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