They aren't the same. An event is an event. A "delegate" assigns a particular event handler to an object instance. Thus, when an object event happens, the proper procedure/method is called.
An example might help. I frequently code things so that a single method is called for all instances of a class. No matter which button is clicked, call my generic "button_click" method. That method will use the event arguments to determine which button was actually clicked.
In order to assign all button click events to a single method, I have to code the delegates.
Event is Arraylist of delegates .
Delegate (as its English meaning) Secretary or someone who connect two persons throuh him .
Delegate can fire only one method
But Event fire more than one delegate , each call one method
Example : in Windows App. or ASP.NET App.
Button : is a class that has internally an event called ( eg. click ) and there is
a method you want to do if this button clicked so make an instance of the delegate
which button.click deal with ( System.EventHandler ) and make this delegate
execute the method eg. Button1_Click
in initializer of The Form Class :
Button1.Click += new System.EventHandler(this.button1_Click) ;
And make amethod :
private void button1_Click(object sender, System.EventArgs e)
// write your own code
Event is a Modifier used to declare a special kind of multicast delegate that can only be invoked from within the class or struct where it is declared (the publisher class).
Events enable a class or object to notify other classes or objects when something of interest occurs. The class that sends (or raises) the event is called the publisher and the classes that receive (or handle) the event are called subscribers.
you can use a multicast delegate instead of an event. but the main reason for using an event is that it prevents the invoking ability from its subscribers. basically events promote encapsulation over multicast delegates.
I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...
Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...