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被形容 ...
随机推荐
- shell入门-awk-1
awk对于sed grep的优势在于分段,把分隔符分割成一小段一小段,针对段进行匹配,替换,操作,逻辑判断,比较...等 awk的基本操作 [root@wangshaojun ~]# awk -F ' ...
- 使用showOptionDialog显示多项选择框
-----------------siwuxie095 工程名:TestJOptionPane 包名:com.siwuxie095.showdi ...
- Add lombok to IntelliJ IDEA
Lombok study link: https://www.jianshu.com/p/365ea41b3573 Add below dependency code to pom.xml <d ...
- 在PCL中如何实现点云压缩(2)
博客转载自:http://www.pclcn.org/study/shownews.php?lang=cn&id=125 压缩配置文件: 压缩配置文件为PCL点云编码器定义了参数集.并针对压缩 ...
- Leetcode: 67. Add Binary
二进制加法 https://discuss.leetcode.com/topic/33693/another-simple-java public String addBinary(String a, ...
- Citrix 虚拟化 最小化后无法最大化
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Citrix\wfshell\TWI\创建DWORD类型键值:SeamlessFlags ...
- AQS(AbstractQueuedSynchronizer)介绍-01
1.概述 AQS( AbstractQueuedSynchronizer ) 是一个用于构建锁和同步器的框架,许多同步器都可以通过AQS很容易并且高效地构造出来.如: ReentrantLock 和 ...
- mobile web页面调试方法
此文已由作者张含会授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 开发过程问题排查 Chrome Emulation关键词:使用方便 模拟各种设备尺寸.像素比.自定义user ...
- 2017-10-6 清北刷题冲刺班p.m
1.数组异或 #include<iostream> #include<cstdio> #define maxn 100010 #define mod 1000000007 us ...
- 洛谷P3396 哈希冲突(分块)
传送门 题解在此,讲的蛮清楚的->这里 我就贴个代码 //minamoto #include<iostream> #include<cstdio> #include< ...