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


// This field is defined by the Manager class



Download 21,46 Mb.
Pdf ko'rish
bet395/1830
Sana28.09.2021
Hajmi21,46 Mb.
#188411
1   ...   391   392   393   394   395   396   397   398   ...   1830
Bog'liq
[book] [en] Pro C# 2008 and the NET 3.5 Platform Fourth Edition

// This field is defined by the Manager class.

numberOfOptions = numbOfOpts;

// Assign incoming parameters using the

// inherited properties of the parent class.

ID = empID;

Age = age;

Name = fullName;

Pay = currPay;

// OOPS! This would be a compiler error,

// as the SSN property is read-only!

SocialSecurityNumber = ssn;

}

The first issue with this approach is that we defined the SocialSecurityNumber property in the



parent as read-only; therefore we are unable to assign the incoming string parameter to this field,

as seen in the final code statement of this custom constructor.

The second issue is that we have indirectly created a rather inefficient constructor, given the

fact that under C#, unless you say otherwise, the default constructor of a base class is called auto-

matically before the logic of the derived constructor is executed. After this point, the current

implementation accesses numerous public properties of the Employee base class to establish its

state. Thus, you have really made seven hits (five inherited properties and two constructor calls)

during the creation of a Manager object!

To help optimize the creation of a derived class, you will do well to implement your subclass

constructors to explicitly call an appropriate custom base class constructor, rather than the default.

In this way, you are able to reduce the number of calls to inherited initialization members (which

saves processing time). Let’s retrofit the custom constructor of the Manager type to do this very thing

using the base keyword:

public Manager(string fullName, int age, int empID,

float currPay, string ssn, int numbOfOpts)


Download 21,46 Mb.

Do'stlaringiz bilan baham:
1   ...   391   392   393   394   395   396   397   398   ...   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