Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个字符串资源,它需要根据条件编译具有不同的值。
如何在 Visual Studio 2008 Professional 中为不同的编译宏设置不同的资源?
没办法。资源字符串以 XML 格式存储在 .resx 文件中,#ifdef 不适用。Properties.Resources 类是自动生成的,当重新生成文件时,您放入 Designer.cs 源代码文件中的任何 #ifdef 都将丢失。
将#ifdef 放入检索字符串的代码中。一个小的静态辅助方法就可以完成这项工作。