Presentation is loading. Please wait.

Presentation is loading. Please wait.

Debug in Visual Studio 98-362 Windows Development Fundamentals LESSON 2.5A.

Similar presentations


Presentation on theme: "Debug in Visual Studio 98-362 Windows Development Fundamentals LESSON 2.5A."— Presentation transcript:

1 Debug in Visual Studio 98-362 Windows Development Fundamentals LESSON 2.5A

2 98-362 Windows Development Fundamentals LESSON 2.5A Lesson Overview What tools does Microsoft Visual Studio ® provide to assist with debugging? In this lesson, you will learn about:  The Debug class  The Visual Studio Debugger

3 98-362 Windows Development Fundamentals LESSON 2.5A Anticipatory Set  Describe a time when you’ve been stumped by a bug in one of your programs.  — How did you try to solve the problem?  — What was the solution?

4 98-362 Windows Development Fundamentals LESSON 2.5A Visual Studio Debugger  Visual Studio provides a set of tools that are useful for debugging applications. Some commonly used tools include:  — Breakpoints: flags that tell the debugger to suspend (or “break”) execution of a program temporarily at a designated point; this allows the developer to examine a variety of data related to the program. This state is known as Break Mode.  While in Break Mode, the developer can step through code, executing one line at a time.  — Step Into: executes a single instruction in the Debugger. If the instruction is a function call, the debugger steps into the function.  — Step Over: like Step Into, this executes a single line of code. However, if the instruction is a function call, the whole function is executed.  — Step Out: executes all instructions until the current function returns to the calling function.  In Break Mode, you can also place the mouse point over a variable to see its current value.

5 98-362 Windows Development Fundamentals LESSON 2.5A Try It Complete the Walkthrough at http://msdn.microsoft.com/en-us/library/kya29xtx.aspx. Note: Stop after completing the 10 steps in the section entitled “Debug Your Form.”

6 98-362 Windows Development Fundamentals LESSON 2.5A Adding a Method Add a method—HelloWorld()—to the application you created.  In Visual Basic ® : Private Sub HelloWorld() TextBox1.Text = "Hello World" TextBox1.Text = "Goodbye World“ End Sub  In Visual C# ® : p rivate void HelloWorld() { TextBox1.Text = "Hello World“; TextBox1.Text = "Goodbye World“; }

7 98-362 Windows Development Fundamentals LESSON 2.5A Invoking the Method In the handler, add a call to the new method after the line with the breakpoint.  In Visual Basic: Private Sub Button1_Click( … ) Handles Button1.Click TextBox1.Text = "Button was clicked!" HelloWorld() End Sub  In Visual C#: private void Button1_Click( … ) { TextBox1.Text = "Button was clicked!“; HelloWorld(); }

8 98-362 Windows Development Fundamentals LESSON 2.5A Stepping Through the Method Call  Run the application.  After entering Break Mode, use Step Into to step through the code until the program resumes.  Click the button again and use Step Over to see the difference.

9 98-362 Windows Development Fundamentals LESSON 2.5A Lesson Review With a partner, answer the following questions: 1. How is Debug.WriteLine different from Console.WriteLine? 2. Explain the difference between Step Into and Step Over.


Download ppt "Debug in Visual Studio 98-362 Windows Development Fundamentals LESSON 2.5A."

Similar presentations


Ads by Google