C# 0 The Complete Reference


PART I C h a p t e r   1 5



Download 4,07 Mb.
Pdf ko'rish
bet548/1096
Sana23.01.2022
Hajmi4,07 Mb.
#402171
1   ...   544   545   546   547   548   549   550   551   ...   1096
Bog'liq
C-Sharp 3 The Complete Reference Herbert Schildt


PART I

C h a p t e r   1 5 :  

D e l e g a t e s ,   E v e n t s ,   a n d   L a m b d a   E x p r e s s i o n s  

433


PART IPART I

  static void Main() {

    MyEvent evt = new MyEvent();

    // Add Handler() to the event list.

    evt.SomeEvent += Handler;

    // Fire the event.

    evt.OnSomeEvent();

  }


}

In this case, the 



EventArgs

 parameter is unused and is passed the placeholder object 



EventArgs.Empty

. The output is shown here:

Event occurred

Source is MyEvent



Applying Events: A Case Study

Events are frequently used in message-based environments such as Windows. In such an 

environment, a program simply waits until it receives a message, and then it takes the 

appropriate action. Such an architecture is well suited for C#-style event handling because it 

is possible to create event handlers for various messages and then simply invoke a handler 

when a message is received. For example, the left-button mouse click message could be tied 

to an event called 

LButtonClick

. When a left-button click is received, a method called 




Download 4,07 Mb.

Do'stlaringiz bilan baham:
1   ...   544   545   546   547   548   549   550   551   ...   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