C# 0 The Complete Reference


PART I C h a p t e r   1 6



Download 4,07 Mb.
Pdf ko'rish
bet567/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   563   564   565   566   567   568   569   570   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt


PART I

C h a p t e r   1 6 :  

  N a m e s p a c e s ,   t h e   P r e p r o c e s s o r ,   a n d   A s s e m b l i e s  

453


PART IPART I

    #endif

    Console.WriteLine("This is in all versions.");

  }


}

This program displays the following:

Compiled for experimental version.

This is in all versions.

The program defines the symbol 

EXPERIMENTAL

. Thus, when the 



#if

 is encountered, 

the symbol expression evaluates to true, and the first 

WriteLine( )

 statement is compiled. 

If you remove the definition of 

EXPERIMENTAL

 and recompile the program, the first 



WriteLine( )

 statement will not be compiled, because the 



#if

 will evaluate to false. In all 

cases, the second 

WriteLine( )

 statement is compiled because it is not part of the 



#if

 block.


As explained, you can use a symbol expression in an 

#if

. For example,

// Use a symbol expression.

#define EXPERIMENTAL

#define TRIAL

using System;

class Test {

  static void Main() {

    #if EXPERIMENTAL

      Console.WriteLine("Compiled for experimental version.");

    #endif

    #if EXPERIMENTAL && TRIAL

       Console.Error.WriteLine("Testing experimental trial version.");

    #endif

    Console.WriteLine("This is in all versions.");

  }


}

The output from this program is shown here:

Compiled for experimental version.

Testing experimental trial version.

This is in all versions.

In this example, two symbols are defined, 




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   563   564   565   566   567   568   569   570   ...   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