You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/debugger/write-better-code-with-visual-studio.md
+15-1Lines changed: 15 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
---
2
2
title: Debugging Techniques and Tools
3
3
description: Write better code with fewer bugs by using Visual Studio to fix exceptions and resolve errors, and make improvements to your code.
4
-
ms.date: 5/22/2026
4
+
ms.date: 06/03/2026
5
5
ms.topic: how-to
6
6
helpviewer_keywords:
7
7
- "debugger"
@@ -224,7 +224,12 @@ When you select this item, Visual Studio adds the `using System.Text` statement
224
224
225
225
The preceding error is a common one that you usually fix by adding a new `using` statement to your code. There are several common, similar errors to this one such as `The type or namespace "Name" cannot be found.` These kinds of errors might indicate a missing assembly reference (right-click the project, choose **Add** > **Reference**), a misspelled name, or a missing library that you need to add (for C#, right-click the project and choose **Manage NuGet Packages**).
226
226
227
+
::: moniker range="visualstudio"
228
+
## Fix the remaining errors
229
+
::: moniker-end
230
+
::: moniker range="vs-2022"
227
231
## Fix the remaining errors and warnings
232
+
::: moniker-end
228
233
229
234
There are a few more squiggles to look at in this code. Here, you see a common type conversion error. When you hover over the squiggle, you see that the code is trying to convert a string to an int, which isn't supported unless you add explicit code to make the conversion.
230
235
@@ -258,6 +263,8 @@ internal int points;
258
263
259
264
The red squiggly lines in the code editor go away.
260
265
266
+
::: moniker range="vs-2022"
267
+
261
268
Next, hover over the green squiggle in the declaration of the `points` data member. The code analyzer tells you the variable is never assigned a value.
262
269
263
270

When you have fixed all the red squiggles at least looked at all the green squiggles, you're ready to start the debugger and run the app.
292
+
::: moniker-end
293
+
294
+
::: moniker range="vs-2022"
282
295
When you have fixed all the red squiggles and resolved—or at least investigated—all the green squiggles, you're ready to start the debugger and run the app.
296
+
::: moniker-end
283
297
284
298
Press **F5** (**Debug > Start Debugging**) or the **Start Debugging** button  in the Debug toolbar.
0 commit comments