|
-
Jan 17th, 2007, 02:11 AM
#1
Thread Starter
Addicted Member
What is delegate? and Use?
Hi,
What is called delegate?. What is the usage? Please tell it in simple way. Please don't give big explanation. I already confused with large theoritical explanation. If possible please give one simple example.
God has been pleased to place as a king or cobbler do the work sincerely
-
Jan 17th, 2007, 02:21 AM
#2
Re: What is delegate? and Use?
OOP is designed to mimic the real world and delegates are no different. I live in Australia and Australia is a member of the UN. If there's a UN meeting then Australia sends a delegate. If there's a ballot then that delegate casts a vote on Australia's behalf, so Australia has voted without actually being there.
In .NET programming a delegate is an object that contains a reference to a method. You can pass that delegate around form method to property just like any other object. When you invoke the delegate it will execute the method it has a reference to, even if the object that the method is a member of is nowhere nearby.
Let's say that you had a Country class and you created an instance named Australia. Australia could create a delegate object and provide it a reference to its Vote method. It could then pass that delegate to another object, which might represent the UN. That object could then call the delegate's Invoke method and, even though the Australia object is not present, its Vote method will be executed.
-
Jan 17th, 2007, 04:15 AM
#3
Hyperactive Member
Re: What is delegate? and Use?
 Originally Posted by jmcilhinney
OOP is designed to mimic the real world and delegates are no different. I live in Australia and Australia is a member of the UN. If there's a UN meeting then Australia sends a delegate. If there's a ballot then that delegate casts a vote on Australia's behalf, so Australia has voted without actually being there.
In .NET programming a delegate is an object that contains a reference to a method. You can pass that delegate around form method to property just like any other object. When you invoke the delegate it will execute the method it has a reference to, even if the object that the method is a member of is nowhere nearby.
Let's say that you had a Country class and you created an instance named Australia. Australia could create a delegate object and provide it a reference to its Vote method. It could then pass that delegate to another object, which might represent the UN. That object could then call the delegate's Invoke method and, even though the Australia object is not present, its Vote method will be executed.
jmcilhinney, Please provide me the explanation of delegate in code so that the concept become more consolidate.
Thanks
Imran Ahmad Mughal
"Visual Studio .NET 2005/.NET Framework 2.0"
The eyes are the greatest telescopes, one will ever need to study the universe. Let the heart be the tripod, the mind be the shaft, then let the eyes become the lens of that great telescope of which God gave to us all.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|