C# 0 The Complete Reference


switch  statement or as the control variable in a  for



Download 4,07 Mb.
Pdf ko'rish
bet428/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   424   425   426   427   428   429   430   431   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

    Bu sahifa navigatsiya:
  • Apple
switch

 statement or as the control variable in a 



for

loop, for example.

Each enumeration symbol is given a value one greater than the symbol that precedes it. 

By default, the value of the first enumeration symbol is 0. Therefore, in the 



Apple

 enumeration, 



Jonathan

 is 0, 


GoldenDel

 is 1, 


RedDel

 is 2, and so on.

The members of an enumeration are accessed through their type name via the dot 

operator. For example

Console.WriteLine(Apple.RedDel + " has the value " +

                  (int)Apple.RedDel);

displays

RedDel has the value 2

As the output shows, when an enumerated value is displayed, its name is used. To obtain 

its integer value, a cast to 



int

 must be employed.

Here is a program that illustrates the 

Apple

 enumeration:

// Demonstrate an enumeration.

using System;

class EnumDemo {

  enum Apple { Jonathan, GoldenDel, RedDel, Winesap,

               Cortland, McIntosh };

  static void Main() {

    string[] color = {

      "Red",

      "Yellow",

www.freepdf-books.com




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   424   425   426   427   428   429   430   431   ...   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