Are .NET resource file strings interned?

自古美人都是妖i 提交于 2019-12-11 00:02:16

问题


When I use a .resx file to store fixed string values (to be bound 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?


回答1:


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



来源:https://stackoverflow.com/questions/4745473/are-net-resource-file-strings-interned

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!