C# 0 The Complete Reference


x , which is 10. In the program,  p



Download 4,07 Mb.
Pdf ko'rish
bet750/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   746   747   748   749   750   751   752   753   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

x

, which is 10. In the program, 



p

 is declared as a pointer to an 



int

and


q

 as a pointer to an 



int

 pointer.

One last point: Do not confuse multiple indirection with high-level data structures, such 

as linked lists. These are two fundamentally different concepts.



Arrays of Pointers

Pointers can be arrayed like any other data type. The declaration for an 



int

 pointer array of 

size 3 is

int * [] ptrs = new int * [3];

To assign the address of an 

int

 variable called 



var

 to the third element of the pointer array, 

write

ptrs[2] = &var;



To find the value of 

var

, write


*ptrs[2]

sizeof

When working in an unsafe context, you might occasionally find it useful to know the size, 

in bytes, of one of C#’s value types. To obtain this information, use the 

sizeof

 operator. It 

has this general form:

sizeof(


type

)

Here, type is the 



type

 whose size is being obtained. In general, 



sizeof

 is intended primarily for

special-case situations, especially when working with a blend of managed and unmanaged 

code.


www.freepdf-books.com


596

 

P a r t   I :  



T h e   C #   L a n g u a g e

stackalloc

You can allocate memory from the stack by using 



stackalloc

. It can be used only when 

initializing local variables and has this general form:

type *p

 = stackalloc 



type

[

size

]

Here, 


p

 is a pointer that receives the address of the memory that is large enough to hold 



size

number of objects of 



type.

 Also, 


type

 must be a nonreference type. If there is not room on the 

stack to allocate the memory, a 


Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   746   747   748   749   750   751   752   753   ...   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