C#中的两种debug方法
第一种:需要把调试方法改成debug
代码用 #if DEBUG 包裹
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
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 > 0) { RootPath = ToolsPath.Substring(0, 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; //必须包含这个包
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#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方法的更多相关文章
- JS中的两种刷新方法以及区别和适用范围
在项目中有一个人信息修改的页面,但是修改后显示的却是修改之前的内容,分析问题后发现查询语句写在了修改语句之前,有些某些需要又必须这么写,但是修改信息后先却显示之前的信息也太不科学了. 所以我就想用js ...
- 将文件放到Android模拟器的SD卡中的两种解决方法
两种方式:一.窗口界面操作1.打开DDMS页面2.打开File Explorer页,如果没有,在Window --> Show View -->File Explorer3.一般就在mnt ...
- C# 的两种debug 方法
第一种:需要把调试方法改成debug代码用 #if DEBUG 包裹 using System; using System.Collections.Generic; using System.Text ...
- Linux系统中存储设备的两种表示方法
转:https://blog.csdn.net/holybin/article/details/38637381 一.对于IDE接口的硬盘的两种表示方法: 1.IDE接口硬盘,对于整块硬盘的两种表示方 ...
- 史上最全的CSS hack方式一览 jQuery 图片轮播的代码分离 JQuery中的动画 C#中Trim()、TrimStart()、TrimEnd()的用法 marquee 标签的使用详情 js鼠标事件 js添加遮罩层 页面上通过地址栏传值时出现乱码的两种解决方法 ref和out的区别在c#中 总结
史上最全的CSS hack方式一览 2013年09月28日 15:57:08 阅读数:175473 做前端多年,虽然不是经常需要hack,但是我们经常会遇到各浏览器表现不一致的情况.基于此,某些情况我 ...
- HTML中label的两种使用方法
如果您在 label 元素内点击文本,就会触发此控件.就是说,当用户选择该标签时,浏览器就会自动将焦点转到和标签相关的表单控件上. 有两种使用方法: 方法1: <label for=" ...
- 两种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的路由系统. 例子
随机推荐
- Android java程序获取assets资产文件
AssetManager assetManager=this.getAssets(); inputStream = assetManager.open("test.xml");
- ANDROID_MARS学习笔记_S04_002_用AsyncTask实现异步操作
一.简介 二.代码1.xml(1)activity_main.xml <?xml version="1.0" encoding="utf-8"?> ...
- 2-3 tree使用
The 2-3 tree is also a search tree like the binary search tree, but this tree tries to solve the pro ...
- UNDO表空间损坏,爆满,ORA-600[4194]/[4193]错误解决
模拟手工删除UNDO表空间 在ORADATA 中把UNDOTBS01.DBF 删除 模拟启库 SQL> STARUP; * 第 1 行出现错误: ORA-01157: 无法标识/锁定数据文件 2 ...
- JavaScript高级程序设计22.pdf
操作节点 appendChild()用于向childNodes列表末尾添加一个节点,appendChild()返回新增的节点 var returnedNode=someNode.appendChild ...
- gcc “-I”(大写i),“-L”(大写l),“-l”(小写l)的区别
我们用gcc编译程序时,可能会用到“-I”(大写i),“-L”(大写l),“-l”(小写l)等参数,下面做个记录: 例: gcc -o hello hello.c -I /home/hello/inc ...
- HW4.26
public class Solution { public static void main(String[] args) { double sum; double item; for(int i ...
- 使用alloctor模板来实现string类
虽然以前做过更复杂的各种数据结构,不过那只是在看完c++prime7章后做的,没有考虑到类的拷贝体现出来是类值还是类指针,于是写了一些半成品类,不过那些主要是练数据结构,不想再改,于是就想办法模仿了下 ...
- SSL 通信及 java keystore 工具介绍
http://www.javacodegeeks.com/2014/07/java-keystore-tutorial.html Table Of Contents 1. Introduction 2 ...
- PC-修改IE 与 禁止修改IE
1.注册表编辑器1.1在Windows启动后1.2点击“开始”1.3“运行”菜单项1.4在“打开”栏中键入“regedit”1.5然后按“确定”键 2.首页项2.1展开注册表到“HKEY_LOCAL_ ...