C# 0 The Complete Reference


EventArgs  called  KeyEventArgs



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

EventArgs

 called 


KeyEventArgs

, which is 

used to pass a keystroke to an event handler. Next, a delegate called 

KeyHandler

 defines 

the event handler for keystroke events. The class 

KeyEvent

 encapsulates the keypress event. 

It defines the event 

KeyPress

.

In



Main( )

, a 


KeyEvent

 object called 



kevt

 is created. Next, an event handler based on 

a lambda expression is added to 

kvet.KeyPress

 that displays each key as it is entered, as 

shown here:

www.freepdf-books.com




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  

435


PART IPART I

kevt.KeyPress += (source, arg) =>

  Console.WriteLine(" Received keystroke: " + arg.ch);

Next, another lambda expression–based handler is added to 



kvet.KeyPress

 by the 


following code. It counts the number of keypresses.

kevt.KeyPress += (source, arg) =>

  count++; // count is an outer variable

Notice that 



count

 is a local variable declared in 



Main( )

 that is initialized to zero.

Next, a loop is started that calls 


Download 4,07 Mb.

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