首页 > 解决方案 > 是否有代码样式选项可以让 Visual Studio 不重新格式化 #pragma 指令?

问题描述

有没有办法告诉 Visual Studio 如何设置 pragma 的样式(例如 , #define, #if, #else, #endif,#region等等)?

通常,pragma 位于一行中的第一个字符。如果我希望它们显示为内联并且不让 Visual Studio 为我重新设置它们的样式,我该怎么做?我在工具 | 中没有看到任何内容 选项 | C# | 代码风格。

namespace MySolution.MyProject
{
    internal class MyClass
    {
        public void MyMethod1()
        {
            #if (USETHIS1)
                // code here
            #else
                // code here
            #endif
        }
    }
}

我在 Stack Overflow 和 Google 上进行了搜索,但没有看到任何内容,可能只是我搜索的方式。编译器接受任何位置的位置。

就标准而言,我更喜欢看到我的编译指示内联,就像上面一样。我怎么能那样做?

标签: c#visual-studiocoding-style

解决方案


推荐阅读