是.NET资源文件中的字符串实习?字符串、文件、资源、NET

2023-09-06 14:28:11 作者:爱你无惧

当我使用.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?