代码取决于构建类型?

Tob*_*ias 3 c# build

我正在使用Visual c#Express 2008.我想在"Release"版本中执行一个特殊的命令 - 在我创建和运行Debug版本时不应该执行此命令.是否可以根据我的构建类型(Debug或.Release)实现代码?

例如:

if(??buildtype?? == "Release")
{
 //... special command ...
 MessageBox.Show("RELEASE version");
}
else
{
//... normal command ...
MessageBox.Show("debug release");
}
Run Code Online (Sandbox Code Playgroud)

Max*_*keh 12

#if DEBUG
  // Commands that should run in debug builds.
#else
  // Commands that should run in release builds.
#endif
Run Code Online (Sandbox Code Playgroud)