C# 的两种debug 方法
第一种:需要把调试方法改成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 方法的更多相关文章
- C#中的两种debug方法
这篇文章主要介绍了C#中的两种debug方法介绍,本文讲解了代码用 #if DEBUG 包裹.利用宏定义两种方法,需要的朋友可以参考下 第一种:需要把调试方法改成debug代码用 #if DEBU ...
- 关于Unity的两种调试方法
Unity的两种调试方法 1.Debug.Log()输出语句调试,平时经常用这个 2.把MonoDevelop和Unity进行连接后断点调试 先把编辑器选择为MonoDevelop,Edit----& ...
- 两种js方法发起微信支付:WeixinJSBridge,wx.chooseWXPay区别
原文链接:https://www.2cto.com/weixin/201507/412752.html 1.为什么会有两种JS方法可以发起微信支付? 当你登陆微信公众号之后,左边有两个菜单栏,一个是微 ...
- keil结合st-link使用SWO的两种调试方法笔记
通过strongerHuang的教程,实现了SWO的两种调试方法, 1.在keil调试的过程中,使用debug printf viewer打印信息, 2.在STM32 ST-LINK Utility中 ...
- angular2系列教程(十)两种启动方法、两个路由服务、引用类型和单例模式的妙用
今天我们要讲的是ng2的路由系统. 例子
- git两种合并方法 比较merge和rebase
18:01 2015/11/18git两种合并方法 比较merge和rebase其实很简单,就是合并后每个commit提交的id记录的顺序而已注意:重要的是如果公司用了grrit,grrit不允许用m ...
- 两种Ajax方法
两种Ajax方法 Ajax是一种用于快速创建动态网页的技术,他通过在后台与服务器进行少量的数据交换,可以实现网页的异步更新,不需要像传统网页那样重新加载页面也可以做到对网页的某部分作出更新,现在这项技 ...
- mysql in 的两种使用方法
简述MySQL 的in 的两种使用方法: 他们各自是在 in keyword后跟一张表(记录集).以及在in后面加上字符串集. 先讲后面跟着一张表的. 首先阐述三张表的结构: s(sno,sname. ...
- Service的两种启动方法
刚才看到一个ppt,介绍service的两种启动方法以及两者之间的区别. startService 和 bindService startService被形容为我行我素,而bindService被形容 ...
随机推荐
- ssh功能模块——paramiko
参考官网文档:http://docs.paramiko.org/
- 关于Synchronized关键字锁住对象的嵌套问题
如果在子关键字代码块中调用了sleep,是否会保留有所的锁?
- 《精通Spring4.X企业应用开发实战》读后感第六章(属性编辑器)
- java之字符
参考http://how2j.cn/k/number-string/number-string-character/323.html 保存一个字符的时候使用char package character ...
- LightOJ 1311 Unlucky Bird (物理题)
题意:有点长,意思是说有一个鸟,在两列火车之间不停的来回飞,两列相距为d时,都开始减速,直到最后停止下来,正好是相距0米, 现在给定两列车的速度和减速时的加速度,和鸟的速度求 d 和鸟飞过的路程. 析 ...
- HDU 5241 Friends (大数)
题意:略. 析:答案就是32^n. 代码如下: import java.math.BigInteger; import java.util.Scanner; public class Main{ pu ...
- The instance of entity type 'xxxx' cannot be tracked because another instance with the same key value for {'Id'} is already being tracked.
一.问题描述 问题:The instance of entity type 'xxxx' cannot be tracked because another instance with the sam ...
- c++第六次实验
part 1 验证性实验 合并两个文件.虽说验证,但后两个实验均受该代码指导启发. part 2 文末添加数据 1.代码 #include<fstream> #include<io ...
- bzoj 3944: Sum(杜教筛)
3944: Sum Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 4930 Solved: 1313[Submit][Status][Discuss ...
- [Xcode 实际操作]四、常用控件-(1)UIButton控件的使用
目录:[Swift]Xcode实际操作 本文将演示按钮控件的使用,按钮是用户界面中最常见的交互控件 在项目导航区,打开视图控制器的代码文件[ViewController.swift] import U ...