Visual Studio 调试(系列文章)

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

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

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

调试方法与技巧
 
示例程序
后续的调试如下面的程序为示例进行演示说明。
 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 }
View Code

 

原文出处:https://www.cnblogs.com/SavionZhang/p/11232376.html编程语言

相关文章
相关标签/搜索