所以我有大约10个简短的css文件,我在mvc应用程序中使用。有像error.css,login.css等等..。只是一些非常短的css文件,使更新和编辑变得容易(至少对我来说)。我想要的是一些东西,可以优化if else分支,而不是将其合并到最后的位中。我想做这样的事情
if(Debug.Mode){
<link rel="stylesheet" type="text/css" href="error.css" />
<link rel="stylesheet" type="text/css" href="login.css" />
<link rel="stylesheet" type="text/css" href="menu.css" />
<link rel="stylesheet" type="text/css" href="page.css" />
} else {
<link rel="stylesheet" type="text/css" href="site.css" />
}我将有一个msbuild任务,它将合并所有的css文件,最小化它们,以及所有的好东西。我只需要知道是否有一种方法可以删除最后一位中的if else分支。
发布于 2008-09-08 23:40:45
具体来说,就像在C#中这样:
#if (DEBUG)
Debug Stuff
#endifC#具有以下预处理器指令:
#if
#else
#elif // Else If
#endif
#define
#undef // Undefine
#warning // Causes the preprocessor to fire warning
#error // Causes the preprocessor to fire a fatal error
#line // Lets the preprocessor know where this source line came from
#region // Codefolding
#endregion 发布于 2008-11-18 15:52:05
if (System.Diagnostics.Debugger.IsAttached)
{
// Do this
}
else
{
// Do that
}发布于 2008-09-08 23:10:00
我应该用谷歌的。
#if DEBUG
Console.WriteLine("Debug mode.")
#else
Console.WriteLine("Release mode.")
#endif 确保选中项目属性中的"Configuration settings“-> "Build”"Define DEBUG constant“选项。
https://stackoverflow.com/questions/50900
复制相似问题