C# Language Specification


Accessibility constraints



Download 0,75 Mb.
bet78/524
Sana06.01.2022
Hajmi0,75 Mb.
#324842
1   ...   74   75   76   77   78   79   80   81   ...   524
Bog'liq
CSharp Language Specification

Accessibility constraints


Several constructs in the C# language require a type to be at least as accessible as a member or another type. A type T is said to be at least as accessible as a member or type M if the accessibility domain of T is a superset of the accessibility domain of M. In other words, T is at least as accessible as M if T is accessible in all contexts in which M is accessible.

The following accessibility constraints exist:



  • The direct base class of a class type must be at least as accessible as the class type itself.

  • The explicit base interfaces of an interface type must be at least as accessible as the interface type itself.

  • The return type and parameter types of a delegate type must be at least as accessible as the delegate type itself.

  • The type of a constant must be at least as accessible as the constant itself.

  • The type of a field must be at least as accessible as the field itself.

  • The return type and parameter types of a method must be at least as accessible as the method itself.

  • The type of a property must be at least as accessible as the property itself.

  • The type of an event must be at least as accessible as the event itself.

  • The type and parameter types of an indexer must be at least as accessible as the indexer itself.

  • The return type and parameter types of an operator must be at least as accessible as the operator itself.

  • The parameter types of an instance constructor must be at least as accessible as the instance constructor itself.

In the example

class A {...}

public class B: A {...}

the B class results in a compile-time error because A is not at least as accessible as B.

Likewise, in the example

class A {...}

public class B
{
A F() {...}

internal A G() {...}

public A H() {...}
}

the H method in B results in a compile-time error because the return type A is not at least as accessible as the method.



    1. Download 0,75 Mb.

      Do'stlaringiz bilan baham:
1   ...   74   75   76   77   78   79   80   81   ...   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