开发者

Are .NET resource file strings interned?

开发者 https://www.devze.com 2023-02-05 22:29 出处:网络
When I use a .resx file to store fixed string values (to be bound开发者_StackOverflow to controls on an .aspx page), are these strings interned?

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

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.

Is this correct?


@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.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消