The purpose of this assignment is to introduce you to the concept of assigning values to fields and debugging in Visual Studio.
Copy and rename First Day 0.3
In Programming Concepts we will be building off of the previous week's assignment so we will be copying over assignments regularly. It will be very important to make sure your previous assignment is correct or the mistakes will follow you to the next assignment.
0.4 First Day 1 Snip CopyFolder.png0.4 First Day 1 Snip RenameFolder.png0.4 First Day 1 Snip RenameSln.pngGo to top
Debug the Book object field values.
No Field Values
Breakpoints stop the application at a specific point in time. This allows us to see specific values while the application is running.
Set Breakpoint
Debugger
If you do not see the Autos Window, go to Debug | Windows | Autos.
Autos Window
The Autos Window shows the "best guess" of what the debugger thinks you want to see. It shows you the Name of the object/field, the Value of the object/field and it's Type. In this case, we have an object of 'this.Student.Backpack.Book' with the Value of {FrstDayScenario.Book} (which signifies it's an object), and a Type of Book. The Book object also has a number of Fields such as AuthorName, Cost, etc. In this case, all the Values shown are default values because we have not assigned anything to them.
Visual Studio has a built in "hint giver" called Intellisense that shows us what we can use/do. It can make life a lot easier, but can also lead you down the wrong path.
Type this.
Intellisense will bring up a list of things that are in the current instance of the current class. Since Student is a field in the MainWindow class and we just assigned a Student field on the line before, Intellisense "guesses" that that is what we want to use.
Student Fields
Note that Intellisense shows the fields for the Student class.
Student Class
In C# the = sign DOES NOT mean "equals" it means "assign to".
Cost Field
The "m" after a number indicates that the value is a decimal type.
Even though we have code that assigns values to the Book's Fields, since the debugger has stopped on line 87 none of those lines of code have executed. Even the AuthorName hasn't been assigned a value even though the debugger is on that line. The line will only execute after the debugger moves off that line.
Step Over
This executes the lines of code and moves the debugger down but does not change the breakpoint.