C# Language Specification


Interface implementations



Download 0,75 Mb.
bet446/524
Sana06.01.2022
Hajmi0,75 Mb.
#324842
1   ...   442   443   444   445   446   447   448   449   ...   524
Bog'liq
CSharp Language Specification

Interface implementations


Interfaces may be implemented by classes and structs. To indicate that a class or struct directly implements an interface, the interface identifier is included in the base class list of the class or struct. For example:

interface ICloneable


{
object Clone();
}

interface IComparable


{
int CompareTo(object other);
}

class ListEntry: ICloneable, IComparable


{
public object Clone() {...}

public int CompareTo(object other) {...}


}

A class or struct that directly implements an interface also directly implements all of the interface’s base interfaces implicitly. This is true even if the class or struct doesn’t explicitly list all base interfaces in the base class list. For example:

interface IControl
{
void Paint();
}

interface ITextBox: IControl


{
void SetText(string text);
}

class TextBox: ITextBox


{
public void Paint() {...}

public void SetText(string text) {...}


}

Here, class TextBox implements both IControl and ITextBox.

When a class C directly implements an interface, all classes derived from C also implement the interface implicitly. The base interfaces specified in a class declaration can be constructed interface types (§4.4). A base interface cannot be a type parameter on its own, though it can involve the type parameters that are in scope. The following code illustrates how a class can implement and extend constructed types:

class C {}

interface I1 {}

class D: C, I1 {}

class E: C, I1 {}

The base interfaces of a generic class declaration must satisfy the uniqueness rule described in §13.4.2.



      1. Download 0,75 Mb.

        Do'stlaringiz bilan baham:
1   ...   442   443   444   445   446   447   448   449   ...   524




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish