1. <i id='j4mfQ'><tr id='j4mfQ'><dt id='j4mfQ'><q id='j4mfQ'><span id='j4mfQ'><b id='j4mfQ'><form id='j4mfQ'><ins id='j4mfQ'></ins><ul id='j4mfQ'></ul><sub id='j4mfQ'></sub></form><legend id='j4mfQ'></legend><bdo id='j4mfQ'><pre id='j4mfQ'><center id='j4mfQ'></center></pre></bdo></b><th id='j4mfQ'></th></span></q></dt></tr></i><div id='j4mfQ'><tfoot id='j4mfQ'></tfoot><dl id='j4mfQ'><fieldset id='j4mfQ'></fieldset></dl></div>

      <small id='j4mfQ'></small><noframes id='j4mfQ'>

      <tfoot id='j4mfQ'></tfoot>
          <bdo id='j4mfQ'></bdo><ul id='j4mfQ'></ul>
      1. <legend id='j4mfQ'><style id='j4mfQ'><dir id='j4mfQ'><q id='j4mfQ'></q></dir></style></legend>

        Visual Studio 忽略 #if DEBUG/RELEASE 范围内的代码,并且不检查错误或自动完成

        Visual Studio ignores the code inside #if DEBUG / RELEASE scope and doesn#39;t check for errors or autocompletes(Visual Studio 忽略 #if DEBUG/RELEASE 范围内的代码,并且不检查错误或自动完成)
        <legend id='bAtbO'><style id='bAtbO'><dir id='bAtbO'><q id='bAtbO'></q></dir></style></legend>

            <bdo id='bAtbO'></bdo><ul id='bAtbO'></ul>

                <i id='bAtbO'><tr id='bAtbO'><dt id='bAtbO'><q id='bAtbO'><span id='bAtbO'><b id='bAtbO'><form id='bAtbO'><ins id='bAtbO'></ins><ul id='bAtbO'></ul><sub id='bAtbO'></sub></form><legend id='bAtbO'></legend><bdo id='bAtbO'><pre id='bAtbO'><center id='bAtbO'></center></pre></bdo></b><th id='bAtbO'></th></span></q></dt></tr></i><div id='bAtbO'><tfoot id='bAtbO'></tfoot><dl id='bAtbO'><fieldset id='bAtbO'></fieldset></dl></div>
                  <tbody id='bAtbO'></tbody>

                <small id='bAtbO'></small><noframes id='bAtbO'>

                <tfoot id='bAtbO'></tfoot>
                  本文介绍了Visual Studio 忽略 #if DEBUG/RELEASE 范围内的代码,并且不检查错误或自动完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我一直在编写 #if DEBUG#else#endif 代码片段,我注意到 Visual Studio 没有'不要让我使用自动完成来完成部分键入的成员名称,并且它不会检查灰色的非活动代码是否存在错误.我发现让它再次受到关注的唯一方法是将构建模式从调试切换到发布.但这很不方便,感觉有更好的方法.

                  I've been writing an #if DEBUG, #else, #endif fragment of code, and I noticed that Visual Studio doesn't let me use autocomplete to fulfill partially typed member names, and it doesn't check the greyed out inactive code for errors. The only way I've found to make it care again is to switch the build mode from Debug to Release. But that's inconvenient and feels like there's a better way.

                  示例:

                  #if DEBUG
                      throw;
                  #else
                      throw new exc // I want to use autocomplete here but can't because it's greyed out
                  #endif
                  

                  如何让 VS 停止忽略 #if DEBUG 的其他配置范围内的其他代码?

                  How do I make VS stop ignoring the other code inside the other configuration's scope of #if DEBUG?

                  推荐答案

                  这是条件编译的目的,它按预期工作.使用条件编译应用程序可以在编译时忽略某些代码.您在 Visual Studio 中的应用程序在调试模式下运行,因此编译器会忽略 #else 部分中的代码.

                  It is purpose of conditional compilation, it is working as intended. With conditional compilation application can ignore certain code at compilation. Your application in Visual Studio is running in Debug Mode so compiler is ignoring code inside #elsepart.

                  Release 模式下运行您的应用程序,然后 #else 代码将可用,但 #if DEBUG 将不可用.

                  Run your application in Release mode then #else code will be available but #if DEBUGwill not be available.

                  更新

                  用于检查 #if DEBUG#else 你需要运行应用程序两次.

                  For checking both #if DEBUG & #else you need to run application twice.

                  1.Once 在 debug 模式下,其中带有 #if DEBUG 的代码如下:

                  1.Once in debug mode in which code with #if DEBUG like :

                  这里应用程序处于调试模式,因此 #if DEBUG 条件代码处于活动状态..

                  here application is in debug mode so #if DEBUG condition code is active..

                  1. release 模式下运行应用程序以检查 #else 条件下的代码.这里的其他部分将能够使用自动完成 &也调试.
                  1. Run application in release mode for checking code in #else condition. Here other part will be able to use autocomplete & debug too.

                  有关更多信息,请参阅 microsoft 文档:

                  Refer microsoft docs for more info on this:

                  https:///docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/debug-compiler-option

                  https:///docs.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-options/listed-by-category

                  这篇关于Visual Studio 忽略 #if DEBUG/RELEASE 范围内的代码,并且不检查错误或自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Force JsonConvert.SerializeXmlNode to serialize node value as an Integer or a Boolean(强制 JsonConvert.SerializeXmlNode 将节点值序列化为整数或布尔值)
                  Using JSON to Serialize/Deserialize TimeSpan(使用 JSON 序列化/反序列化 TimeSpan)
                  Could not determine JSON object type for type quot;Classquot;(无法确定类型“Class的 JSON 对象类型.)
                  How to deserialize a JSONP response (preferably with JsonTextReader and not a string)?(如何反序列化 JSONP 响应(最好使用 JsonTextReader 而不是字符串)?)
                  how to de-serialize JSON data in which Timestamp it-self contains fields?(如何反序列化时间戳本身包含字段的JSON数据?)
                  JSON.Net custom contract serialization and Collections(JSON.Net 自定义合约序列化和集合)
                • <legend id='gnxFU'><style id='gnxFU'><dir id='gnxFU'><q id='gnxFU'></q></dir></style></legend>

                • <small id='gnxFU'></small><noframes id='gnxFU'>

                    <tfoot id='gnxFU'></tfoot>
                      <tbody id='gnxFU'></tbody>
                    <i id='gnxFU'><tr id='gnxFU'><dt id='gnxFU'><q id='gnxFU'><span id='gnxFU'><b id='gnxFU'><form id='gnxFU'><ins id='gnxFU'></ins><ul id='gnxFU'></ul><sub id='gnxFU'></sub></form><legend id='gnxFU'></legend><bdo id='gnxFU'><pre id='gnxFU'><center id='gnxFU'></center></pre></bdo></b><th id='gnxFU'></th></span></q></dt></tr></i><div id='gnxFU'><tfoot id='gnxFU'></tfoot><dl id='gnxFU'><fieldset id='gnxFU'></fieldset></dl></div>
                      <bdo id='gnxFU'></bdo><ul id='gnxFU'></ul>