473,382 Members | 1,369 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Help understanding user created Delegates

RSH
I have been looking at delegates lately. I have seen several articles
explaining them but I'm having a hard time understanding why I would use a
delegate over a traditional function or sub. Could someone please help me
understand why i would use a delegate in day to day use, over a function or
sub?

Thank you for your time!
Ron
Oct 16 '06 #1
2 1075
Well, I hope this helps a little. Here's how I use them a lot.
When I add controls at runtime, I use the AddHandler VB function, often, to
direct a call of a particular event at one routine I've written to handle
the group of controls. This enables me to write only one function to handle
the event of the group of controls I've added. This is a very nice feature
that is enabled via delegates.

Another way delegates can be used, apriori .NET 2.0, is perhaps in
collections. Buy using a delegate, I could write different method to handle
functionality for different types of object. So, a search function could be
handled by a delegate and you could handle search for whatever kind of
object.
I say apriori because with .NET 2.0 we now have generics.

HTH
Steve

"RSH" <wa*************@yahoo.comwrote in message
news:u9**************@TK2MSFTNGP02.phx.gbl...
>I have been looking at delegates lately. I have seen several articles
explaining them but I'm having a hard time understanding why I would use a
delegate over a traditional function or sub. Could someone please help me
understand why i would use a delegate in day to day use, over a function or
sub?

Thank you for your time!
Ron

Oct 16 '06 #2
RSH
That is very interesting!

I am still having a bit of a problem conceptualizing where I might use this
outside of event trapping.

Thanks!
Ron

"RSH" <wa*************@yahoo.comwrote in message
news:u9**************@TK2MSFTNGP02.phx.gbl...
>I have been looking at delegates lately. I have seen several articles
explaining them but I'm having a hard time understanding why I would use a
delegate over a traditional function or sub. Could someone please help me
understand why i would use a delegate in day to day use, over a function or
sub?

Thank you for your time!
Ron

Oct 16 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: serge calderara | last post by:
Dear all, I have an application which is suppose to start another executable process. As soon as that process is running, I need to retrive its handle. The problem of the particular process I am...
22
by: Jeff Louie | last post by:
Well I wonder if my old brain can handle threading. Dose this code look reasonable. Regards, Jeff using System; using System.Diagnostics; using System.IO; using System.Threading;
12
by: serge calderara | last post by:
Dear all, I have an application which is suppose to start another executable process. As soon as that process is running, I need to retrive its handle. The problem of the particular process I am...
2
by: hcaptech | last post by:
This is my Test.can you help me ? 1.Which of the following statement about C# varialble is incorrect ? A.A variable is a computer memory location identified by a unique name B.A variable's name...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.