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被形容 ...
随机推荐
- CodeForces 492C Vanya and Exams (贪心)
C. Vanya and Exams time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Saving output of a grep into a file with colors
19 down vote favorite 7 I need to save the result of a grep command into a file, but I also want the ...
- Spark Task 概述
Task的执行流程: 1. Driver端中的 CoarseGrainSchedulerBackend 给 CoarseGrainExecutorBacken 发送 LaunchTask 消息 2. ...
- lyd的旅行
lyd的旅行 众所周知,lyd是一个人赢.他有很多很多的妹子.某天,他带着他的众多妹子进行了一次旅(dou)行(feng),由于lyd的车上妹子太多超重了,所以车速每秒最多只能改变d个单位,lyd在出 ...
- 对不起,给pandas配表情包太难了,pandas你该这么学,No.6
如果图片无法观看,请移步 https://blog.csdn.net/hihell 标题起的长,才能引起你的注意呢 昨天,有个家伙,留言给我说 嫌我不好好写博客 就知道给文章配表情包 在这里,郑重的回 ...
- Bitbucekt Reference
Bitbucket Server installation guide https://confluence.atlassian.com/bitbucketserver/bitbucket-serve ...
- tput 命令行使用说明
转载自:https://blog.csdn.net/fdipzone/article/details/9993961 什么是 tput?tput 命令将通过 terminfo 数据库对您的终端会话进行 ...
- asddf
https://docs.saltstack.com/en/getstarted/fundamentals/index.html https://pypi.org/simple/cherrypy/ 安 ...
- 《SQL 进阶教程》 自连接排序
子查询所做的,是计算出价格比自己高的记录的条数并将其作为自己的位次 -- 自连接实现排序功能SELECT P1.name,P1.price,(SELECT COUNT(P2.price)FROM Pr ...
- Ubuntu16.04安装Nvidia显卡驱动+Cuda8.0+Cudnn6.0
一.安装Nvidia显卡驱动(gtx1050ti) 参考链接:Ubuntu16.04.2 LTS 64bit系统装机记录中的显卡驱动安装部分. 二.安装Cuda8.0 1.确定自己的系统信息,以Ubu ...