Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Лаба №1 / books / csharp_ebook.pdf
Скачиваний:
63
Добавлен:
03.03.2016
Размер:
3.69 Mб
Скачать

Programmers Heaven: C# School

Visual Studio.Net & its IDE (Integrated Development Environment)

Most of the time, you will be using Visual Studio.Net to develop Windows applications in C#. Visual Studio.Net provides a lot of tools to help develop applications and cuts out a lot of work for the programmer. Visual Sutdio.Net provides a standard code editor and IDE for all .Net applications, along with a standard debugger, project and solution settings, form designer, integrated compiler and lot of other useful tools.

IntelliSense and Hot Compiler

The Visual Studio.Net IDE provides a standard text editor to write .Net applications. The text editor is loaded with IntelliSense and a hot compiler. IntelliSense gives the text editor the ability to suggest different options in the programming context. For example, when you place a dot after the name of an object, the IDE automatically provides you a list of all the members (properties, methods, etc) of the object. The following figure shows IntelliSense at work in the Visual Studio.Net IDE.

The hot compiler highlights the syntax errors in your program as you type the code. The following figure shows an illustration of the hot compiler at work in Visual Studio.Net.

196

Programmers Heaven: C# School

Code Folding

One of the pleasant new features introduced in Visual Studio.Net is code folding. With code folding, you can fold/unfold the code using the + and - symbols. Usually the code can be folded/unfolded at each scope boundary (method, class, namespace, property, etc). You can also define regions within your code and can fold/unfold the code within the region. The region is defined using the #region...#endregion preprocessor directives.

Integrated Compiler, Solution builder and Debugger

Visual Studio.Net provides an integrated compiler to compile and execute your application during development. You can either compile a single source file or the complete project and solution (a group of files that make up an application). Once you have compiled your application, you can debug it using the Visual Studio.Net debugger. You can even create an installer for your application using Visual Studio.Net!

Form Designer

Perhaps the most useful feature of the Visual Studio.Net IDE is its form designer. The form designer allows you to design the graphical user interface just by placing the controls on the form from the Toolbox. You can set a lot of properties of the form and its controls using the Properties window.

The Visual Studio.Net IDE automatically writes the code in the source file as you place the controls on the form and change their properties. You can also use the IDE to create and set up the event handlers for your controls. The following figure presents an introductory view of the Visual Studio.Net Form Designer and its different supporting windows.

197

Programmers Heaven: C# School

You can see the toolbox window at the left hand side (#1) and the properties window at the right hand side (#2) of the above snapshot. The toolbox allows you to add different controls to your form. Once the control is placed on the form, you can change its various properties from the Properties window. You can also change the location and size of the controls using the mouse. Event properties can be changed by switching to the Event Poperties pane (#3) in the Properties Window.

The Toolbox, Properties Window, Help Window, Solution Explorer Window, Class View Window, Output Window and other helping windows in Visual Studio IDE can be set for Docking and Auto hiding. Windows that are set for auto hide appears only when they get focus (e.g. they have mouse pointer over them or receive a mouse click), and hide when they lose focus. A window can be set for auto hide by the button marked #4 in the above figure. The hidden windows are always accessible through the left and right hand panes of the form designer window. The right hand pane is marked with #5 in the above figure and has got the class view, help and solution explorer windows in the hidden state. If some of these windows are not visible in your visual studio IDE, you can make them visible from the View menu on the standard menu bar.

Solution Explorer

The Solution Explorer is a very useful window. It presents the files that make up the solution in a tree structure. A solution is a collection of all the projects and other resources that make up a .Net application. A solution may contain projects created in different .Net based languages like VB.Net, VC#.Net and VC++.Net. The following figure presents a snapshot of the Visual Studio.Net Solution Explorer.

198

Programmers Heaven: C# School

The Reference node contains all the assemblies referenced in the respective project. 'App.ico' is the icon file for the application. AssemblyInfo.cs is a C# file that contains information about the current assembly. Form1.cs in the above figure is the name of the source file of the program.

A .Net solution is saved in a .sln file, a C# project is saved in a .csproj file and C# source code is saved in a .cs file. It is important to understand here that Projects and Solutions are standards of Visual Studio.Net and are not the requirement of any .Net language. In fact, the language compiler is not even aware of any project or solution.

Menus in the Visual Studio .Net IDE

File Menu: Used to create, open, save and close the project, solution or individual source files.

Edit Menu: Used for text editing and searching in the Visual Studio source code editor.

View Menu: Provides options for setting the visibility of different Visual Studio windows and to switch between code and designer views.

Project Menu: Used for setting different properties of the Visual Studio Project. A Visual Studio project is a collection of files that make up a single assembly or a single object file (we will explore the concept of assemblies in coming lessons).

Build Menu: This menu is used to compile and build the source file, project or solution. The result of a build is an executable file or a code library.

Debug Menu: This menu provides various options related to the Visual Studio.Net Debugger. Debugging is the process of finding logical errors in the program, and a debugger helps make this process easier.

Data Menu: Provides various options for Data Access in .Net

199

Соседние файлы в папке books