This print for content only-size & color not accurate 7" X 9-1/4" / casebound / malloy



Download 21,46 Mb.
Pdf ko'rish
bet592/1830
Sana28.09.2021
Hajmi21,46 Mb.
#188411
1   ...   588   589   590   591   592   593   594   595   ...   1830
Bog'liq
[book] [en] Pro C# 2008 and the NET 3.5 Platform Fourth Edition

A More Elaborate Cloning Example

Now assume the Point class contains a reference type member variable of type PointDescription.

This class maintains a point’s friendly name as well as an identification number expressed as a

System.Guid (if you don’t come from a COM background, know that a globally unique identifier

[GUID] is a statistically unique 128-bit number). Here is the implementation:

// This class describes a point.

public class PointDescription

{

// Exposed publicly for simplicity.

public string petName;

public Guid pointID;

public PointDescription()

{

this.petName = "No-name";



pointID = Guid.NewGuid();

}

}



The initial updates to the Point class itself included modifying ToString() to account for these

new bits of state data, as well as defining and creating the PointDescription reference type. To allow

the outside world to establish a pet name for the Point, you also update the arguments passed into

the overloaded constructor:

public class Point : ICloneable

{

public int x, y;



public PointDescription desc = new PointDescription();

public Point(){}

public Point(int x, int y)

{

this.x = x; this.y = y;



}

public Point(int x, int y, string petname)

{

this.x = x;



this.y = y;

desc.petName = petname;

}

C H A P T E R   9  




Download 21,46 Mb.

Do'stlaringiz bilan baham:
1   ...   588   589   590   591   592   593   594   595   ...   1830




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