最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
浅析C#中的Debug类及方法
时间:2022-06-25 08:09:47 编辑:袖梨 来源:一聚教程网
位于命名空间System.Diagnostics中
1.Debug.Print方法
Debug.Print("Today: {0}", DateTime.Today);
2.Debug.WriteLine方法
Debug.WriteLine("Have a nice day");
3.TraceListener类
DelimitedListTraceListener创建的时候指定一个文件名,当Flush调用的时候,就被覆写到文件里。
TraceListener listener = new DelimitedListTraceListener(@"C:debugfile.txt");
// Add listener.
Debug.Listeners.Add(listener);
// Write and flush.
Debug.WriteLine("Welcome");
Debug.Flush();
4.Debug.Write和WriteIf以及WriteLineIf方法
Debug.WriteLineIf(IsThursday(), "Thursday");
第一个参数一个bool值,为真则输出。
5.Debug.Assert方法
Debug.Assert(value != -1, "Value must never be -1.");
如果表达式为false,则输出。
相关文章
- 百炼英雄怎么挂机 挂机方式及各等级最优点位攻略 12-15
- 百炼英雄vip礼包码大全 最新可用vip礼包码 12-15
- 光与影33号远征队符文收集:强力复生符文效果及获取方式详解 12-15
- 百炼英雄兑换码有哪些 最新可用兑换码及兑换方式 12-15
- 神器传说怎么克制闪避流 闪避流克制阵容实战攻略 12-15
- 神器传说怎么打异兽分最高 异兽冲榜高分搭配 12-15