C#中#region,#if的作用

#reion
#endregion

作用:折叠并隐藏代码

#if
#else
#endif

作用:控制编译的代码
例如: 
       #if(condition) 
              代码A 
       #else 
              代码B 
       #endif
如果condition为真,则程序编译的时候只编译代码A,如果condition为假,则程序编译的时候只编译代码B
所以, 
      #if 
      #else 
      #endif
只是一个起控制预编译的代码;如果不加#,当然就是一个简单的判断语句。

posted @ 2013-06-27 14:06  springstudent  阅读(371)  评论(0编辑  收藏  举报