Debugging is an important part of the software development cycle. It’s challenging, confusing and vexing at the same time. In general, for slightly larger programs, debugging is inevitable. In recent years, the development of debugging tools has made many debugging tasks easier and more time-saving.
1 Hover the mouse to see the expression value
Debugging can be challenging. For example, you can see where the error occurred by running step by step within the function, and you can know who called the function by viewing the stack information, etc.
But in any case, it is very troublesome to view the values of expressions and local variables (put the expressions and local variables in the watch window).
A simpler method is to stop the mouse on the data you want to view. If it is a class or structure, you can click to expand it to quickly and easily view its fields.
2 Change variable values during operation
# The debugger is not only a tool to analyze program crashes and strange behaviors, but also can inspect data through step-by-step debugging Many bugs are solved by solving the problem of whether the behavior is as expected by the program. Sometimes, you wonder if you could set certain conditions to be true so that your program would run correctly. In fact, you just move the mouse over the variable, double-click the value, and enter the value you need. This way there is no need to modify the code or restart the program.
3 Set the next running position
A typical debugging case is that we often use the step-by-step debugging method to analyze why the function went wrong. At this time, you encounter an error returned by this function calling other functions, and this error is not what you want. What should you do? Restart debugger? Here is a better way, just drag the yellow running position arrow to the running position you want. In fact, it means skipping the intermediate running code and going directly to the desired location. It's very simple.
4 Edit and continue running
When running a very complex program and plug-in, an error is found, but you don’t want to waste time recompiling and restarting program.
It’s very simple, just modify the bug at this location and continue debugging. Visual studio will modify the program so that you can continue debugging without restarting the program.
It is worth noting that the "Edit and Continue" function has several limitations. One, it doesn't work on 64-bit code. If you want to use this feature, go to the compilation options in the project settings and select "x86" as the target platform. Don't worry, the release configuration of this target platform is separate from "debug", which means it is still the setting of "Any CPU". Second, the "Edit and continue running" function only applies to changes within a function. If you want To change the declaration of this function or add a new method, you can only choose to restart the program or continue without making any changes. If the modified method contains a lambda expression, it means that the delegate type automatically generated by the compiler has been modified, so Will cause the compiler to stop running.
5 A convenient viewing window
In the debugging window, you can not only view ordinary variable values, you can even enter $handles to track the number of open handles, and $err to view the error code of the function (then use Tools->Error to view the description of the error code) or Type @eax (@rax on 64-bit) to view the register value containing the function return value
6 Comment disassembly
Use the internal disassembly. The assembly function makes it easier to optimize local code. Visual studio can display assembly instructions under each line of your code, and can debug assembly code step by step, and set breakpoints at any location similar to c++ ##.
Debugging multi-threaded code is painful. Might be interesting too. It depends on your debugger. A great feature of Visual studio is to view the stack information of threads in the thread window. You can easily see all threads and their stack information directly.
8 Conditional Breakpoint
If you want to reproduce a small probability event, but the breakpoint will trigger under a large number of unnecessary conditions. You can easily set conditional breakpoints. Set the breakpoint condition in the breakpoint window, and Visual studio will automatically ignore breakpoints that do not meet the conditions.
9 Memory Window
Some bugs are caused by incorrect structure definitions, lack of alignment attributes, etc. Viewing the contents of each line of memory makes it easy to locate and resolve these bugs. Visual studio's memory window can translate data into 8/16/32/64-bit numbers or floating point numbers. You can change the value directly in the editing window.
10 Jump to definition
#If you are solving a bug in the code written by others, you will encounter "What is this type?" "What does this function do?" "What" and other issues, you can use visual studio's jump to definition command to view the definition of the type or function.
11 Command Window
This little trick was suggested by chaau and it can save you a lot of time. Visual studio supports a command window, which you can open through the menu View->Other Windows->Command Window. You can enter different commands in the window to automate debugging. For example, you can test MFC's COleDateTime variable with a very simple command.
The above are 11 Visual Studio debugging skills shared with you. I hope it will be helpful to your learning.
For more articles related to the summary of Visual Studio debugging skills, please pay attention to the PHP Chinese website!

To start C#.NET development, you need to: 1. Understand the basic knowledge of C# and the core concepts of the .NET framework; 2. Master the basic concepts of variables, data types, control structures, functions and classes; 3. Learn advanced features of C#, such as LINQ and asynchronous programming; 4. Be familiar with debugging techniques and performance optimization methods for common errors. With these steps, you can gradually penetrate the world of C#.NET and write efficient applications.

The relationship between C# and .NET is inseparable, but they are not the same thing. C# is a programming language, while .NET is a development platform. C# is used to write code, compile into .NET's intermediate language (IL), and executed by the .NET runtime (CLR).

C#.NET is still important because it provides powerful tools and libraries that support multiple application development. 1) C# combines .NET framework to make development efficient and convenient. 2) C#'s type safety and garbage collection mechanism enhance its advantages. 3) .NET provides a cross-platform running environment and rich APIs, improving development flexibility.

C#.NETisversatileforbothwebanddesktopdevelopment.1)Forweb,useASP.NETfordynamicapplications.2)Fordesktop,employWindowsFormsorWPFforrichinterfaces.3)UseXamarinforcross-platformdevelopment,enablingcodesharingacrossWindows,macOS,Linux,andmobiledevices.

C# and .NET adapt to the needs of emerging technologies through continuous updates and optimizations. 1) C# 9.0 and .NET5 introduce record type and performance optimization. 2) .NETCore enhances cloud native and containerized support. 3) ASP.NETCore integrates with modern web technologies. 4) ML.NET supports machine learning and artificial intelligence. 5) Asynchronous programming and best practices improve performance.

C#.NETissuitableforenterprise-levelapplicationswithintheMicrosoftecosystemduetoitsstrongtyping,richlibraries,androbustperformance.However,itmaynotbeidealforcross-platformdevelopmentorwhenrawspeediscritical,wherelanguageslikeRustorGomightbepreferable.

The programming process of C# in .NET includes the following steps: 1) writing C# code, 2) compiling into an intermediate language (IL), and 3) executing by the .NET runtime (CLR). The advantages of C# in .NET are its modern syntax, powerful type system and tight integration with the .NET framework, suitable for various development scenarios from desktop applications to web services.

C# is a modern, object-oriented programming language developed by Microsoft and as part of the .NET framework. 1.C# supports object-oriented programming (OOP), including encapsulation, inheritance and polymorphism. 2. Asynchronous programming in C# is implemented through async and await keywords to improve application responsiveness. 3. Use LINQ to process data collections concisely. 4. Common errors include null reference exceptions and index out-of-range exceptions. Debugging skills include using a debugger and exception handling. 5. Performance optimization includes using StringBuilder and avoiding unnecessary packing and unboxing.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

WebStorm Mac version
Useful JavaScript development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Atom editor mac version download
The most popular open source editor