C# 0 The Complete Reference


PART I C h a p t e r   2 0



Download 4,07 Mb.
Pdf ko'rish
bet777/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   773   774   775   776   777   778   779   780   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt


PART I

C h a p t e r   2 0 :  

U n s a f e   C o d e ,   P o i n t e r s ,   N u l l a b l e   T y p e s ,   a n d   M i s c e l l a n e o u s   T o p i c s  

611


PART IPART I

    }


  }

}

Notice that both 



test1.cs

 and 


test2.cs

 define a namespace called 



MyNS

, and that within 

that namespace, both files define a class called 

MyClass

. Thus, without an 



extern

 alias, no 

program could have access to both versions of 

MyClass

.

The third file, 



test3.cs

, which is shown next, uses 



MyClass

 from both 



test1.cs

 and 


test2.cs

. It is able to do this because of the 



extern

 alias statements.

// extern alias statements must be at the top of the file.

extern alias Asm1;

extern alias Asm2;

using System;

class Demo {

  static void Main() {

    Asm1::MyNS.MyClass t = new Asm1::MyNS.MyClass();

    Asm2::MyNS.MyClass t2 = new Asm2::MyNS.MyClass();

  }

}

Start by compiling 



test1.cs

 and 


test2.cs

 into DLLs. This can be easily done from the 

command line by using these commands:

csc /t:library test1.cs

csc /t:library test2.cs

Next, compile 



test3.cs

 by using this command line:

csc /r:Asm1=test1.dll /r:Asm2=test2.dll test3.cs

Notice the use of the 



/r

 option, which tells the compiler to reference the metadata found in 

the associated file. In this case, the alias 


Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   773   774   775   776   777   778   779   780   ...   1096




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