第一种:需要把调试方法改成debug
代码用 #if DEBUG 包裹

using System;
using System.Collections.Generic;
using System.Text;
using System.IO; namespace SplitPackage
{
public static class EnvConfig
{
static EnvConfig()
{
#if DEBUG
ToolsPath = @"D:\workspace\shopstyle\tool";
#else
ToolsPath = Environment.CurrentDirectory;
#endif
int rootIdx = ToolsPath.LastIndexOf(@"\");
if (rootIdx > )
{
RootPath = ToolsPath.Substring(, rootIdx);
}
}
public static string ToolsPath { get; private set; }
public static string TmplateFile { get { return Path.Combine(ToolsPath, @"template\default.pm"); } }
public static string RootPath { get; private set; }
public static string ModulePath { get { return Path.Combine(RootPath, "module"); } }
public static string ConfigPath { get { return Path.Combine(RootPath, "conf"); } } }
}

第二种:
利用宏定义

#define DEBUG// C#的宏定义必须出现在所有代码之前。当前我们只让DEBUG宏有效。
using System.Diagnostics;  //必须包含这个包

#define DEBUG

using System.Diagnostics; 

namespace TestConsole
{
class ToolKit
{
[ConditionalAttribute("LI")] // Attribute名称的长记法
[ConditionalAttribute("DEBUG")]
public static void Method1() { Console.WriteLine("Created By Li, Buged.11"); } [ConditionalAttribute("LI")]
[ConditionalAttribute("NOBUG")]
public static void Method2() { Console.WriteLine("Created By Li, NoBug."); } [Conditional("ZHANG")] // Attribute名称的短记法
[Conditional("DEBUG")]
public static void Method3() { Console.WriteLine("Created By Zhang, Buged.11"); } [Conditional("ZHANG")]
[Conditional("NOBUG")]
public static void Method4() { Console.WriteLine("Created By Zhang, NoBug."); }
}
static void Main(string[] args)
{
ToolKit.Method1();
ToolKit.Method2();
ToolKit.Method3();
ToolKit.Method4();
}
}
}

C# 的两种debug 方法的更多相关文章

  1. C#中的两种debug方法

    这篇文章主要介绍了C#中的两种debug方法介绍,本文讲解了代码用 #if DEBUG 包裹.利用宏定义两种方法,需要的朋友可以参考下   第一种:需要把调试方法改成debug代码用 #if DEBU ...

  2. 关于Unity的两种调试方法

    Unity的两种调试方法 1.Debug.Log()输出语句调试,平时经常用这个 2.把MonoDevelop和Unity进行连接后断点调试 先把编辑器选择为MonoDevelop,Edit----& ...

  3. 两种js方法发起微信支付:WeixinJSBridge,wx.chooseWXPay区别

    原文链接:https://www.2cto.com/weixin/201507/412752.html 1.为什么会有两种JS方法可以发起微信支付? 当你登陆微信公众号之后,左边有两个菜单栏,一个是微 ...

  4. keil结合st-link使用SWO的两种调试方法笔记

    通过strongerHuang的教程,实现了SWO的两种调试方法, 1.在keil调试的过程中,使用debug printf viewer打印信息, 2.在STM32 ST-LINK Utility中 ...

  5. angular2系列教程(十)两种启动方法、两个路由服务、引用类型和单例模式的妙用

    今天我们要讲的是ng2的路由系统. 例子

  6. git两种合并方法 比较merge和rebase

    18:01 2015/11/18git两种合并方法 比较merge和rebase其实很简单,就是合并后每个commit提交的id记录的顺序而已注意:重要的是如果公司用了grrit,grrit不允许用m ...

  7. 两种Ajax方法

    两种Ajax方法 Ajax是一种用于快速创建动态网页的技术,他通过在后台与服务器进行少量的数据交换,可以实现网页的异步更新,不需要像传统网页那样重新加载页面也可以做到对网页的某部分作出更新,现在这项技 ...

  8. mysql in 的两种使用方法

    简述MySQL 的in 的两种使用方法: 他们各自是在 in keyword后跟一张表(记录集).以及在in后面加上字符串集. 先讲后面跟着一张表的. 首先阐述三张表的结构: s(sno,sname. ...

  9. Service的两种启动方法

    刚才看到一个ppt,介绍service的两种启动方法以及两者之间的区别. startService 和 bindService startService被形容为我行我素,而bindService被形容 ...

随机推荐

  1. 【转】经典网文:追MM与设计模式

    设计模式做为程序员的“内功心法”,越来越受到.net 社区的重视,这种变化是很可喜的,Java社区走在了我们的前面,但这种状况也许有一天会发生改变. 从追MM谈Java的23种设计模式1.FACT ...

  2. [hdu1402]A * B Problem Plus(NTT)

    解题关键:快速数论变换NTT模板. 注意$ans$数组的$ans[n]$一定要注意置$0$,或者结果从$n-1$开始遍历,这里很容易出错. 代码1:ACdreamer 的板子. 为什么要reverse ...

  3. 转:Linux下用Jmeter做接口测试

    本地设计 首先在本地设计 Apache JMeter 测试计划,大家可以参考<接口测试之 JMeter 初探> ,这里不再重复. 服务器配置 确保服务器已经安装了JDK和Python. 在 ...

  4. Getting the System Version

    #include <windows.h>#include <tchar.h>#include <stdio.h>#include <strsafe.h> ...

  5. Django 之 logging

    1. logging 1.1 什么是 logging logging 模块是 Python 内置的日志管理模块,不需要额外安装. 使用: import logging logging.critical ...

  6. streaming kafka direct 详解

    http://blog.cloudera.com/blog/2015/03/exactly-once-spark-streaming-from-apache-kafka/ http://www.jia ...

  7. python学习笔记11 ----线程、进程、协程

    进程.线程.协程的概念 进程和线程是操作系统中两个很重要的概念,对于一般的程序,可能有若干个进程,每一个进程有若干个同时执行的线程.进程是资源管理的最小单位,线程是程序执行的最小单位(线程可共享同一进 ...

  8. [CentOS7] Segmentation fault (core dumped),但是在主机上找不到core文件

    1.问题描述 程序执行报:Segmentation fault (core dumped),但是在主机上找不到core文件 2.如何让系统生成core file /home>ulimit -ac ...

  9. (linux)安装redis---简装

    redis是当前比较热门的NOSQL系统之一,它是一个key-value存储系统.和Memcached类似,但很大程度补偿了memcached的不足,它支持存储的value类型相对更多,包括strin ...

  10. shell之hello world

    [root@localhost sh]#vi hello.sh //编辑 .sh 文件 #The first program #!/bin/bash echo 'hello world' [root@ ...