C#中的编译开关

时间:2022-10-09 16:11:20

c#不支持宏定义,只支持编译开关。

======================================
我想加上#define xxx就编译a代码,否则编译b代码,像这样的:
#if xxx
a
#else
b
#endif

============================================

//#define Timing
#define Channel

上面两个,任意选一个,就说明开关打开了

#if Timing     [#define Timing]
phy.StartInfo.FileName = "DrawTiming.exe";
#elif Channel
phy.StartInfo.FileName = "DrawChannel.exe";
#else
phy.StartInfo.FileName = "DrawPhysical.exe";
#endif

如果需要默认支持识别Debug的话

C#中的编译开关