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



Download 21,46 Mb.
Pdf ko'rish
bet730/1830
Sana28.09.2021
Hajmi21,46 Mb.
#188411
1   ...   726   727   728   729   730   731   732   733   ...   1830
Bog'liq
[book] [en] Pro C# 2008 and the NET 3.5 Platform Fourth Edition

// Just to be safe, perform a

// runtime check before casting.

if (sender is Car)

{

Car c = (Car)sender;



c.CrankTunes(false);

}

Console.WriteLine("Critical Message from {0}: {1}", sender, e.msg);



}



Source Code

The PrimAndProperCarEvents project is located under the Chapter 11 subdirectory.



The Generic EventHandler Delegate

Given that so many custom delegates take an object as the first parameter and an EventArgs

descendent as the second, you could further streamline the previous example by using the generic

EventHandler type, where T is your custom EventArgs type. Consider the following update to the

Car type (notice how we no longer need to build a custom delegate type at all):

public class Car

{

public event EventHandler Exploded;



public event EventHandler AboutToBlow;

...


}

The Main() method could then make use of EventHandler anywhere we previ-

ously specified CarEventHandler:

static void Main(string[] args)

{

Console.WriteLine("***** Prim and Proper Events *****\n");



// Make a car as usual.

Car c1 = new Car("SlugBug", 100, 10);




Download 21,46 Mb.

Do'stlaringiz bilan baham:
1   ...   726   727   728   729   730   731   732   733   ...   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