C# 0 The Complete Reference


Avoiding Unreachable Code



Download 4,07 Mb.
Pdf ko'rish
bet189/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   185   186   187   188   189   190   191   192   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

Avoiding Unreachable Code

When creating methods, you should avoid causing a situation in which a portion of code 

cannot, under any circumstances, be executed. This is called 

unreachable code,

 and it is 

considered incorrect in C#. The compiler will issue a warning message if you create a 

method that contains unreachable code. For example:

public void MyMeth() {

  char a, b;

  // ...

  if(a==b) {

    Console.WriteLine("equal");

    return;

  } else {

    Console.WriteLine("not equal");

    return;

  }


  Console.WriteLine("this is unreachable");

}

Here, the method 



MyMeth( )

 will always return before the final 



WriteLine( )

 statement is 

executed. If you try to compile this method, you will receive a warning. In general, unreachable 

code constitutes a mistake on your part, so it is a good idea to take unreachable code 

warnings seriously.

Constructors

In the preceding examples, the instance variables of each 



Building

 object had to be set 

manually using a sequence of statements, such as

www.freepdf-books.com




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   185   186   187   188   189   190   191   192   ...   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