惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

I
InfoQ
G
Google Developers Blog
Engineering at Meta
Engineering at Meta
月光博客
月光博客
博客园 - 聂微东
博客园 - Franky
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
有赞技术团队
有赞技术团队
A
About on SuperTechFans
Microsoft Azure Blog
Microsoft Azure Blog
Blog — PlanetScale
Blog — PlanetScale
U
Unit 42
T
Tailwind CSS Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
云风的 BLOG
云风的 BLOG
S
SegmentFault 最新的问题
F
Fortinet All Blogs
H
Help Net Security
J
Java Code Geeks
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 叶小钗
L
LangChain Blog
Martin Fowler
Martin Fowler
N
Netflix TechBlog - Medium

博客园 - 点点滴滴

C#操作IIS的代码 恢复误删数据(SQL Server 2000)--Log Explorer 如何让ClickOnce进行手动更新(含代码) - 点点滴滴 - 博客园 BackgroundWorker 组件 获取VS.NET 自带的数据库连接对话框的数据库连接 搜索一个局域网中所有的SQL Server服务器 Application.DoEvent() 在C#使用XML注释 用IDisposable接口释放.NET资源 正确的重载operator C#调用API访问其它进程 抽象 虚方法 接口 的区别 ASP.NET AJAX 路线图 ASP.NET AJAX 概述 安装ASP.NET AJAX Visitor Template Method Strategy State
很好的debug有理由不用吗
点点滴滴 · 2006-12-16 · via 博客园 - 点点滴滴

        虽然代码写了这么久,不怕你笑话,我对Debug的功能用的很少,甚至极少,在写代码过程中经常使用 MessageBox.Show(....)来进行调试, 或者设置断点来逐步来调试.现在看了下网上的教程,才知道其实不是这么回事. 
  
       Debug的功能现在使用了一下,真是不简单,现将其中最主要的代码列出,以供参考
      名称空间必须引用        System.Diagnostics;

 1using System;
 2using System.Collections.Generic;
 3using System.Text;
 4using System.Diagnostics;
 5
 6namespace ConsoleApplication1
 7{
 8    class Program
 9    {
10        static void Main(string[] args)
11        {
12            int x =1 ,y =2;
13            Debug.WriteLine("Test");//输出控制台
14            Debug.Indent();  //增加缩进
15            Debug.WriteIf(x != y, " x != y ");//条件输出控制台  
16            x = y;
17            Debug.Unindent();  //减少缩进
18            Debug.WriteIf(x == y, " x == y "); //条件输出控制台
19            Debug.Assert(x == y);  //条件不满足则触发一个异常
20
21            //            Debug.Listeners
22
23            //输出结果放在文件里
24            TextWriterTraceListener tr2 = new TextWriterTraceListener(System.IO.File.CreateText("Output.txt"));
25            Debug.Listeners.Add(tr2);
26            Debug.WriteLine("Output Text ");//输出内容
27
28            Debug.Flush();//确保每个 Listener 对象收到它的所有输出,请为 Debug 类缓冲区调用 Flush 方法
29        }

30    }

31}

32