By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,887 Members | 1,246 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,887 IT Pros & Developers. It's quick & easy.

Delegates and Events Handler, what is the defference???

P: n/a
al
Greetings,

Can someone please tell me the what is the defference betweeen
delegates and events handler???
MTIA,
Grawsha
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"al" <gr*********@yahoo.com> schrieb
Greetings,

Can someone please tell me the what is the defference betweeen
delegates and events handler???


An event handler is a procedure that handles events. A delegate is an object
pointing to a procedure, and the procedure can be an event handler but it
does not have to be.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2

P: n/a
> Can someone please tell me the what is the defference betweeen
delegates and events handler???


..NET application raise events. They can (and should) be handled by a special
set of subs, ie.

Private Sub cbMyCombo_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles cbServerType.SelectedIndexChanged

this sub handles SelectedIndexChanged event for ComboBox control

Delegates, on the other hand, are like C++ pointers to functions, but more
powerful. From VS.NET help:

"It is a reference type that refers to a Shared method of a type or to an
instance method of an object. The closest equivalent of a delegate in other
languages is a function pointer, but whereas a function pointer can only
reference Shared functions, a delegate can reference both Shared and
instance methods. In the latter case, the delegate stores not only a
reference to the method's entry point, but also a reference to the object
instance with which to invoke the method."

Events and delegates are closely associated in Visual Basic .NET. An event
is a message sent by an object announcing that something important has
happened. Events are implemented using delegates, a form of object-oriented
function pointer that allows a function to be invoked indirectly by way of a
reference to the function.

sincerely,
--
Sebastian Zaklada
Skilled Software
http://www.skilledsoftware.com
************************************
SQL Source Control 2003 - for
SQL Server Source Safe integration
and custom databases documentation
Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.