Chapter 5: Creating and Building Projects

129

For Each grade In grades

Console.WriteLine(" - " & grade)

Next

Console.ReadKey()

End Sub

End Module

One item to draw your attention to in Listing 5-2 is the using directive (Imports in VB), specifying that you can use the types in the ClassLibraryDemo namespace without fully qualifying them. After that, you can see how Listing 5-2 creates instances of Student and myStudent and calls GetStudentGrades.

TIP

The call to Console.ReadKey in Listing 5-2 causes program execution to stop until the user presses a key on their keyboard. If Console.ReadKey was not present, the program would finish the Main method, which would close the application before you had the chance to see the output.

Next, you’ll want to compile the code to see if the syntax is good and then run the program to see if it operates properly. The next section explains how compiling and running works with VS.

Compiling Applications

You’ll find several compilation options on the Build menu. Because there are so many options, it isn’t always intuitive which option you should use. The options are scoped to either the current project or the entire solution. The top portion of the menu applies to the entire solution, and the second section is context-sensitive, applying to the currently selected project. The following sections describe each set of options, including build, rebuild, and clean for both projects and solutions.

Building Solutions/Projects

Building typically means that you run the compiler to compile source code files. Sometimes the build includes more than compilation. For example, if you are writing ASP.NET applications, VS will generate code based on the Web controls on the page and then that generated code will be compiled with normal code. Therefore, the term build is more accurate than compile.

During a normal build, VS will only build the items in a project or solution that are out of date. More specifically, only projects that have changes and edits will be rebuilt,

Page 152
Image 152
Microsoft 9GD00001 manual Compiling Applications, Building Solutions/Projects, 129