前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Visual Studio 调试(系列文章)

Visual Studio 调试(系列文章)

作者头像
张传宁IT讲堂
发布2019-09-17 18:20:07
7120
发布2019-09-17 18:20:07
举报

调试是软件开发过程中非常重要的一个部分,它具挑战性,但是也有一定的方法和技巧。

  Visual Studio 调试程序有助于你观察程序的运行时行为并发现问题。 该调试器可用于所有 Visual Studio 编程语言及其关联的库。 使用调试程序时,可以中断程序的执行以检查代码、检查和编辑变量、查看寄存器、查看从源代码创建的指令,以及查看应用程序占用的内存空间。

  本系列以 Visual Studio 2019 来演示调试的方法和技巧。希望能帮助大家掌握这些技巧。它们都很简单,却能帮你节约大量的时间。

调试方法与技巧

Visual Studio 调试系列1 Debug 与 Release 模式

Visual Studio 调试系列2 基本调试方法

Visual Studio 调试系列3 断点

Visual Studio 调试系列4 单步后退来检查旧应用状态(使用使用 IntelliTrace 窗口)

Visual Studio 调试系列5 检查变量(使用自动窗口和局部变量窗口)

Visual Studio 调试系列6 监视变量(使用监视窗口和快速监视窗口)

Visual Studio 调试系列7 查看变量占用的内存(使用内存窗口)

Visual Studio 调试系列8 查找导致程序崩溃的 DLL(使用模块窗口)

Visual Studio 调试系列9 调试器提示和技巧

Visual Studio 调试系列10 附加到正在运行的进程

Visual Studio 调试系列11 远程调试

Visual Studio 调试系列12 远程调试部署在远程计算机IIS上的ASP.NET应用程序

示例程序

后续的调试以下面的程序为示例进行演示说明。

代码语言:javascript
复制
  1 using System;
  2 using System.Collections.Generic;
  3 
  4 namespace Demo002_NF45_CS50
  5 {
  6     class Program
  7     {
  8         static void Main(string[] args)
  9         {
 10             var shapes = new List<Shape>
 11             {
 12                 new Triangle(4,3),
 13                 new Rectangle(7,4),
 14                 new Circle(),
 15 
 16             };
 17 
 18             foreach (var shape in shapes)
 19             {
 20                 shape.Width = 10;
 21                 shape.Draw();
 22 
 23                 int num1 = 2, num2 = 0;
 24                 num1 = num1 / num2;
 25 
 26                 Console.WriteLine();
 27             }
 28 
 29             Console.WriteLine("Press any key to exit."); // 在调试模式下保持控制台打开
 30             Console.ReadKey();
 31         }
 32     }
 33 
 34     #region 调试示例
 35 
 36     /// <summary>
 37     ///  绘图类(基类)
 38     /// </summary>
 39     public class Shape
 40     {
 41         #region 属性
 42 
 43         /// <summary>
 44         ///  X 轴坐标
 45         /// </summary>
 46         public int X { get; private set; }
 47 
 48         /// <summary>
 49         ///  Y 轴坐标
 50         /// </summary>
 51         public int Y { get; private set; }
 52 
 53         /// <summary>
 54         ///  图形高度
 55         /// </summary>
 56         public int Height { get; set; }
 57 
 58         /// <summary>
 59         ///  图形宽度
 60         /// </summary>
 61         public int Width { get; set; }
 62 
 63         #endregion
 64 
 65         // 绘制图形(虚方法)
 66         public virtual void Draw()
 67         {
 68             Console.WriteLine("Performing base class drawing tasks");// 执行基类绘图任务
 69         }
 70     }
 71 
 72     /// <summary>
 73     ///  圆形
 74     /// </summary>
 75     class Circle : Shape
 76     {
 77         public override void Draw()
 78         {
 79             Console.WriteLine("Drawing a circle"); // 绘制一个圆
 80             base.Draw();
 81         }
 82     }
 83 
 84     /// <summary>
 85     ///  矩形
 86     /// </summary>
 87     class Rectangle : Shape
 88     {
 89         public Rectangle()
 90         {
 91           
 92         }
 93 
 94         public Rectangle(int width, int height)
 95         {
 96             Width = width;
 97             Height = height;
 98         }
 99 
100         public override void Draw()
101         {
102             Console.WriteLine("Drawing a rectangle"); // 绘制一个矩形
103             base.Draw();
104         }
105     }
106 
107     /// <summary>
108     ///  三角形
109     /// </summary>
110     class Triangle : Shape
111     {
112         public Triangle()
113         {
114 
115         }
116 
117         public Triangle(int width, int height)
118         {
119             Width = width;
120             Height = height;
121         }
122 
123         public override void Draw()
124         {
125             Console.WriteLine("Drawing a trangle");// 绘制一个三角形
126             base.Draw();
127         }
128     }
129 
130     #endregion
131 }
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019-08-01 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
远程调试
远程调试(Remote Debugging,RD)在云端为用户提供上千台真实手机/定制机/模拟器设备,快速实现随时随地测试。运用云测技术对测试方式、操作体验进行了优化,具备多样性的测试能力,包括随时截图和记录调试日志,稳定的支持自动化测试, 设备灵活调度,用例高效执行, 快速定位产品功能和兼容性问题。云手机帮助应用、移动游戏快速发现和解决问题,节省百万硬件费用,加速敏捷研发流程。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档