Debugging is a very important part of the software development process, it is challenging, but there are certain methods and techniques.
Visual Studio debugger helps you look at program runtime behavior and identify problems. The debugger can be used for all Visual Studio programming languages and their associated libraries. When using the debugger, you can interrupt the execution of the program to check the code, check and edit variables, view the register, see the instructions created from the source code, and see the memory space occupied by the application.
This series Visual Studio 2019 to demonstrate the methods and techniques for debugging. We are hoping to help you master these skills. They are very simple, but it can help you save a lot of time.
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 Exit to the any Key. " ); // kept open in debug mode console 30 the Console.ReadKey (); 31 is } 32 } 33 is 34 is #region debugging example 35 36 /// <Summary> 37 [ /// drawing classes (class-yl) 38 is /// </ Summary> 39 public class the Shape 40 { 41 is #region attribute 42 is 43 is /// <Summary> 44 is /// X-axis coordinate 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 /// pattern width 60 /// </ Summary> 61 is public int the Width { GET ; SET ;} 62 is 63 is #endregion 64 65 // draw graphics (virtual method) 66 public Virtual void the Draw () 67 { 68 Console.WriteLine ( " performing base class drawing tasks " ); // perform drawing task group class 69 } 70 } 71 is 72 /// <Summary> 73 is /// circular 74 /// </ Summary> 75 class Circle: the Shape 76 { 77 public the override void the Draw () 78 { 79 Console.WriteLine ( " Drawing Circle A " ); // draw a circle 80 Base .Draw (); 81 } 82 } 83 84 /// <Summary> 85 /// rectangle 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("A Rectangle Drawing " ); // draw a rectangle 103 Base .Draw (); 104 } 105 } 106 107 /// <Summary> 108 /// triangle 109 /// </ Summary> 110 class Triangle: the Shape 111 { 112 public Triangle () 113 { 114 115 } 1 16 117 public Triangle ( int width, int height) 1 18 { 119 = The Width width; 120 the Height = height; 121 } 122 123 public the override void the Draw () 124 { 125 Console.WriteLine ( " Drawing Trangle A " ); // draw a triangle 126 Base .Draw (); 127 } 128 } 129 130. #endregion 131 is }