C# Language Specification


Members of constructed types



Download 0,75 Mb.
bet341/524
Sana06.01.2022
Hajmi0,75 Mb.
#324842
1   ...   337   338   339   340   341   342   343   344   ...   524
Bog'liq
CSharp Language Specification

Members of constructed types


The non-inherited members of a constructed type are obtained by substituting, for each type-parameter in the member declaration, the corresponding type-argument of the constructed type. The substitution process is based on the semantic meaning of type declarations, and is not simply textual substitution.

For example, given the generic class declaration

class Gen
{
public T[,] a;

public void G(int i, T t, Gen gt) {...}

public U Prop { get {...} set {...} }

public int H(double d) {...}


}

the constructed type Gen> has the following members:

public int[,][] a;

public void G(int i, int[] t, Gen,int[]> gt) {...}

public IComparable Prop { get {...} set {...} }

public int H(double d) {...}

The type of the member a in the generic class declaration Gen is “two-dimensional array of T”, so the type of the member a in the constructed type above is “two-dimensional array of one-dimensional array of int”, or int[,][].

Within instance function members, the type of this is the instance type (§10.3.1) of the containing declaration.

All members of a generic class can use type parameters from any enclosing class, either directly or as part of a constructed type. When a particular closed constructed type (§4.4.2) is used at run-time, each use of a type parameter is replaced with the actual type argument supplied to the constructed type. For example:

class C


{
public V f1;
public C f2 = null;

public C(V x) {


this.f1 = x;
this.f2 = this;
}
}

class Application


{
static void Main() {
C x1 = new C(1);
Console.WriteLine(x1.f1); // Prints 1

C x2 = new C(3.1415);


Console.WriteLine(x2.f1); // Prints 3.1415
}
}

      1. Download 0,75 Mb.

        Do'stlaringiz bilan baham:
1   ...   337   338   339   340   341   342   343   344   ...   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