C# 0 The Complete Reference


new  to invoke a  constructor or by simply declaring an object. If  new



Download 4,07 Mb.
Pdf ko'rish
bet423/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   419   420   421   422   423   424   425   426   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt

new

 to invoke a 

constructor or by simply declaring an object. If 

new

 is used, then the fields of the structure 

will be initialized either by the default constructor, which initializes all fields to their default 

value, or by a user-defined constructor. If 



new

 is not used, as is the case with 



book3

, then 


the object is not initialized, and its fields must be set prior to using the object.

When you assign one structure to another, a copy of the object is made. This is an 

important way in which 

struct

 differs from 



class

. As explained earlier in this book, when 

you assign one class reference to another, you are simply making the reference on the left 

side of the assignment refer to the same object as that referred to by the reference on the 

right. When you assign one 

struct

 variable to another, you are making a 



copy

 of the object on 

the right. For example, consider the following program:

// Copy a struct.

using System;

// Define a structure.

struct MyStruct {

  public int x;

}

// Demonstrate structure assignment.



class StructAssignment {

www.freepdf-books.com




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   419   420   421   422   423   424   425   426   ...   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