today when i saw the code about our project,i discover the EventHandler delegate.it’s so fun.we can define a customer class who inherits from EventArgs,we can do somethings about change the value in this class.then we declare an event of delegate type EventHandler of my customer class,when my value changed will send an event message,if somewhere accept the message,will call the function that’s registed to the event. there is a quesion why my class should inherits from EventArgs? because delegate type EventHandler has two params(object, EventArgs),we must send an EventArgs param. 1.define a class who inherits from EventArg 2.declare an event 3.regist an event 4.trriger the event when our value changed
近期评论