C# 0 The Complete Reference



Download 4,07 Mb.
Pdf ko'rish
bet203/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   199   200   201   202   203   204   205   206   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

N

OTE

N

OTE

If you come from a C or C++ background, pay special attention to the way arrays are 

declared. Specifically, the square brackets follow the type name, not the array name.

Here is an example. The following creates an 



int

 array of ten elements and links it to an 

array reference variable named 

sample

.

int[] sample = new int[10];



The

sample

 variable holds a reference to the memory allocated by 



new

. This memory is 

large enough to hold ten elements of type 

int

.

As is the case when creating an instance of a class, it is possible to break the preceding 



declaration in two. For example:

int[] sample;

sample = new int[10];

In this case, when 



sample

 is first created, it refers to no physical object. It is only after the 

second statement executes that 

sample

 refers to an array.

An individual element within an array is accessed by use of an index. An 

index

 describes 

the position of an element within an array. In C#, all arrays have 0 as the index of their first 

element. Because 



sample

 has 10 elements, it has index values of 0 through 9. To index an 

array, specify the number of the element you want, surrounded by square brackets. Thus, 

the first element in 




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   199   200   201   202   203   204   205   206   ...   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