C# 0 The Complete Reference


PART I C h a p t e r   2 0



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


PART I

C h a p t e r   2 0 :  

U n s a f e   C o d e ,   P o i n t e r s ,   N u l l a b l e   T y p e s ,   a n d   M i s c e l l a n e o u s   T o p i c s  

597


PART IPART I

To create a fixed-size buffer, use this form of 



fixed

:

fi xed 



type buf

-

name

[

size

];

Here, 



type

 is the data type of the array; 



buf

-

name

 is the name of the fixed-size buffer; and 

size

 is 


the number of elements in the buffer. Fixed-size buffers can be specified only within a 

struct

.

To understand why a fixed-size buffer might be useful, consider a situation in which 



you want to pass bank account information to an account management program that is 

written in C++. Furthermore, assume that each account record uses the following organization:

Name

An 8-bit, ASCII character string, 80 bytes long



Balance

A

double



, 8 bytes long

ID

A



long

, 8 bytes long

In C++, each structure, itself, contains the 

Name

 array. This differs from C#, which would 

normally just store a reference to the array. Thus, representing this data in a C# 

struct

requires the use of a fixed-size buffer, as shown here:

// Use a fixed-size buffer.

unsafe struct FixedBankRecord {

  public fixed byte Name[80]; // create a fixed-size buffer

  public double Balance;

  public long ID;

}

By using a fixed-size buffer for 




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   749   750   751   752   753   754   755   756   ...   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