【问题标题】:In ReSharper Templates Explorer - What is the difference between the #if and if templates?在 ReSharper 模板资源管理器中 - #if 和 if 模板有什么区别?
【发布时间】:2018-11-29 17:50:39
【问题描述】:

我正在使用 ReSharper 中的 C# 实时模板。我开始这样做是因为this 的问题。当我在 Visual Studio 中获得 ReSharper 模板资源管理器时,我看到有一个 #if 模板和一个 if 模板。我的问题是为什么?

我已通读 ReSharper 帮助 here,但这并没有真正说明它(对我而言)。我也试过取消选中每个模板。 if 模板似乎是 ReSharper if sn-p,但我无法弄清楚 #if 模板的用途。

这是 Visual Studio if sn-p 吗?如果是这样,为什么我在智能感知寡妇中看不到两者?

我知道这是一个非常小的问题,但我只是想知道。谢谢。

【问题讨论】:

    标签: visual-studio resharper


    【解决方案1】:

    #ifpreprocessor directive 其中 if 是 C# selection statement

    例子:

    #if DEBUG
        Console.WriteLine("Debug version");
    #endif
    

    bool condition = true;
    
    if (condition)
    {
        Console.WriteLine("The variable is set to true.");
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-01-03
      • 1970-01-01
      • 1970-01-01
      • 2011-08-26
      • 2017-06-04
      • 2018-03-01
      相关资源
      最近更新 更多