delegate - part 1

Could someone explain what the heck it delegate and provide a sample?  I'm confused.
VBdotnet2005Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mikal613Commented:
Fernando SotoRetiredCommented:
hI VBdotnet2005;

Here is a site on delegates:

A Beginner's Guide to Delegates:
Has downloadable VB .Net Project showing its use.

    http://www.codeproject.com/vb/net/Delegate.asp#xx1428967xx

Fernando
PockyMasterCommented:
A delegate is merely a function pointer.

With a delegate you describe what a function you can call from 'another place' looks like

e.g.

public delegate sub MyDelegate(var as String)

Meaning: the function you are passing will look like:
sub MyDelegate(var as String)


You can create vars of that type and call it like a function:
dim myDel as MyDelegate

myDel("werwer")
NOTE: myDel needs to be instantiated first:

e.g. from your class that actually contains the real method:

dim myDelegateClass as new myDelegateClass
myDelegateClass.SetMyDelegate(Addressof MySubThatLooksTheSameLikeMyDelegate)

And in this class you will have a method like:

private sub MySubThatLooksTheSameLikeMyDelegate (werwer as String)

....

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.