当前位置:编程学习 > C#/ASP.NET >>

C#让代码运行exe时执行,而时Debug不执行

1、C#让代码运行exe时执行,而时Debug不执行
 
if (!Debugger.IsAttached)
{
 Console.Write("Process is running"+"\r\n");
}
 
 
 
2、另外说一下预编译指令:#region、#endregion:在C#中我们经常用到,此指令主要是将代码分割成给定名称的块,与Visiual studio中的大纲显示功能配套使用,主要是美化代码,便于读取用的。#define、#undef:用于定义和取消条件编译的变量,必须定义在其他编译的代码之前,也就是放到using namespace的上面。#if、#else、#elif、#endif:判断哪些代码需要进行编译,哪些代码不需要进行编译。
 
 
 
例子: #define debug
 
 
#if DEBUG
       Console.Write("debug");
   #elif RELEASE
    Console.Write("realse");
   #else
    Console.Write("other");
   #endif
 
 
还有其他几个预编译的指令,不过用的很少,就不说他们了。
 
 
补充:软件开发 , C# ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,