logo
CSharp_Prog_Guide

Другие типы

Интерфейсы, объявленные непосредственно в пространстве имен, можно объявить как открытые или внутренние, и подобно классам и структурам, интерфейсам по умолчанию присваивается внутренний доступ. Члены интерфейса всегда являются открытыми, поскольку целью интерфейса является предоставление возможности доступа к классу или структуре другим типам. Модификаторы доступа нельзя применить к членам интерфейса.

Члены перечисления всегда являются открытыми, и модификаторы доступа не применяются.

По умолчанию делегаты всегда имеют внутренний доступ.

Partial Classes and Methods

It is possible to split the definition of a class or a struct, an interface or a method over two or more source files. Each source file contains a section of the type or method definition, and all parts are combined when the application is compiled.

Partial Classes

There are several situations when splitting a class definition is desirable:

public partial class Employee

{

public void DoWork()

{

}

}

public partial class Employee

{

public void GoToLunch()

{

}

}

The partial keyword indicates that other parts of the class, struct, or interface can be defined in the namespace. All the parts must use the partial keyword. All the parts must be available at compile time to form the final type. All the parts must have the same accessibility, such as public, private, and so on.