Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
CSharp_Prog_Guide.doc
Скачиваний:
16
Добавлен:
16.11.2019
Размер:
6.22 Mб
Скачать

Состав проекта Свойства

Под узлом Свойства представлены параметры конфигурации, применяемые ко всему проекту и хранящиеся в файле CSPROJ в папке решения. Эти параметры включают параметры компиляции, параметры безопасности, развертывания и многие другие. Для изменения проекта используется Конструктор проектов, представляющий собой набор Страниц свойств, который можно открыть, щелкнув правой кнопкой мыши на узле Свойства и выбрав команду Открыть.

Ссылки

В контексте проекта ссылка определяет двоичный файл, необходимый для выполнения приложения. Как правило, ссылка определяет файл DLL, такой как один из файлов библиотеки классов .NET Framework. Ссылка может также определять связь со сборкой .NET (оболочка совместимости), что позволяет приложению вызывать методы в COM-объекте или собственной библиотеке Win32 DLL. Если программа создает экземпляр класса, определенного в другой сборке, на этот файл необходимо создать ссылку в проекте, прежде чем компилировать его. Чтобы добавить ссылку, в меню Проект выберите пункт Добавить ссылку. По умолчанию все проекты C# содержат ссылку на библиотеку mscorlib.dll, в которой находятся основные классы .NET Framework. Ссылки можно добавить на другие библиотеки DLL .NET Framework и файлы, выбрав в меню Проект команду Добавить ссылку.

Примечание.

Не следует путать понятия “ссылка проекта“ и “ссылочные типы” в языке C# или других языках программирования. Первое относится к файлу и его предполагаемому местоположению на диске. Второе – к типам C#, объявленным при помощи ключевого слова class.

Resources

A resource is data that is included with your application but can be stored in such a way that it can be modified independently from the other source code. For example, you can store all your strings as resources instead of hard-coding them into the source code. You can then translate the strings into different languages at some later date, and add them to the application folder that you ship to customers without having to recompile your assembly. The five types of resources defined by Visual C# are as follows: strings, images, icons, audio, and files. You add, remove, or edit resources by using the Resource Designer, which is accessed on the Resources tab in the Project Designer.

Forms

When you create a Windows Forms project, Visual C# adds one form to the project and calls it Form1. The two files that represent the form are called Form1.cs and Form1.designer.cs. You write your code in Form1.cs; the designer.cs file is where the Windows Forms Designer writes the code that implements all the actions that you performed by dragging and dropping controls from the Toolbox.

You can add a new form by clicking the Project command, and selecting Add Windows Form. Each form has two files associated with it. Form1.cs, or whatever you might name it, contains the source code that you write to configure the form and its controls, such as list boxes and text boxes, and responds to events such as button clicks and keystrokes. In simple Windows Forms projects, you do most or all your coding in this file.

The designer.cs file contains the source code that the Forms Designer writes when you drag controls onto the form, set properties in the Properties window, and so on. Typically, you should not edit this file manually at all.

Note:

Obviously, if you create a console application project, it will not contain source code files for Windows Forms.