Beginning Programming with the Visual Studio NET Environment
Beginning Programming with the Visual Studio. NET Environment
n n Visual Studio. NET is a tool-rich programming environment containing all the functionality you'll need to create large or small C# projects. (You can even create projects that seamlessly combine modules from different languages. )
n In the first exercise, you'll start the Visual Studio. NET programming environment and learn how to create a console application.
n n n In the Project Types pane, click the Visual C# Projects folder. In the Templates pane, click the Console Application icon. (You might need to use the Templates pane scrollbar to reveal this icon. ) In the Location field, type C: Visual C# Step by StepChapter 1. In the Name field, type Text. Hello. Click OK. The new project opens.
n n The menu bar provides access to the commands you'll use in the programming environment. You can use the keyboard or the mouse to access the menus and commands exactly as you can in all Windows-based programs. The toolbar is located beneath the menu bar and provides button shortcuts to run the most frequently used commands
n n The Code pane displays the source files. In a multifile project, each source file has its own tab labeled with the name of the source file. You can click the tab once to bring the named source file to the foreground in the Code pane. The Solution Explorer displays the names of the files associated with the project. You can also double-click a filename in the Solution Explorer to bring that source file to the foreground in the Code pane.
n The Output pane lists the diagnostic messages generated from build commands.
n n n Before writing the code, examine the files listed in the Solution Explorer that Visual Studio. NET has created as part of your project: Text. Hello. sln. This is the top-level solution file, of which there is one per application. Each solution file contains one or more project files. In the file system, each solution file has the extension. sln. In the Solution Explorer, it appears with a name that is easier to read, such as "Solution ‘Text. Hello'" in this project. Text. Hello. csproj. This is a C# project file. Each project file contains one or more source files. The source files in a single project must be written in the same programming language. This file type is displayed in the Solution Explorer using only the project's name; however, it is stored on the file system with the extension. csproj. Class 1. cs. This is a C# source file. You will write your code in this file. It contains some code that Visual Studio. NET provides automatically, which you will examine shortly. Assembly. Info. cs. This is another C# source file. You can use this file to add attributes to your program, such as the name of the author, the date the program was written, and so on. There are other more advanced attributes you can use to modify the way in which the program will run. App. ico. This is the icon that is associated with the application. All Windows applications that have a user interface have an icon that appears minimized on the taskbar when the application is running.
Create a console application in Visual Studio. NET n n n In Microsoft Windows, click the Start button, point to All Programs, and then point to Microsoft Visual Studio. NET 2003. Click the Microsoft Visual Studio. NET 2003 icon. Visual Studio. NET starts. On the File menu, point to New, and then click Project. The New Project dialog box opens. This dialog box allows you to create a new project using various templates such as Windows Application, Class Library, and Console Application that specify the type of application you want to create.
Writing Your First Program n n The Class 1. cs file defines a class called Class 1 that contains a method called Main. All methods must be defined inside a class. The Main method is special—it designates the program's entry point. It must be a static method. Write the code using Intelli. Sense technology
- Slides: 10