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



Download 21,46 Mb.
Pdf ko'rish
bet863/1830
Sana28.09.2021
Hajmi21,46 Mb.
#188411
1   ...   859   860   861   862   863   864   865   866   ...   1830
Bog'liq
[book] [en] Pro C# 2008 and the NET 3.5 Platform Fourth Edition

// Calling a custom constructor.

Point pt = new Point(10, 16) { X = 100, Y = 100 };

Given the current definition of our Point type, calling the custom constructor while using ini-

tialization syntax is not terribly useful (and more than a bit verbose). However, if our Point type

provides a new constructor that allows the caller to establish a color (via a custom enumeration

named PointColor), the combination of custom constructors and object initialization syntax

becomes clear. Assume we have updated Point as follows:

public enum PointColor

{ LightBlue, BloodRed, Gold }

public class Point

{

public int xPos, yPos;



private PointColor c;

public Point(PointColor color)

{

xPos = 0; yPos = 0;



c = color;

}

public Point(){}



public Point(int x, int y)

{

xPos = x; yPos = y;



c = PointColor.Gold;

}

...



public override string ToString()

{ return string.Format("[{0}, {1}, Color = {2}]", xPos, yPos, c); }

}

With this new constructor, we can now create a golden point (positioned at 90, 20) as follows:




Download 21,46 Mb.

Do'stlaringiz bilan baham:
1   ...   859   860   861   862   863   864   865   866   ...   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