Professional Documents
Culture Documents
5 Slides
5 Slides
5 Slides
Deleg ates
I need a variable that references a method
A delegate is a type that references methods
public delegate void Writer(string message);
Class Logger
{
public void WriteMessage(String message)
{
Console.WriteLine(message);
}
}
Events
Allows a class to send notifications to other classes or objects
Publisher raises the event
One or more subscribers process the event
Button
subscriber
Subscribere Subscribere
Click
Subscribere
subscriber Subscribere
subscriber
Subscribing To Events
Exercise
Viết một chương trình đơn giản minh họa quản lý tài khoản ATM: khi rút
tiền hoặc chuyển tiền thì hệ thống sẽ gởi tự động tin nhắn đến handphone
của chủ tài khoản cho biết số dư tài khoản, ngày giờ rút tiền,..vv