Answer Posted / kishoreg
Delegates in C#
If we look at C++ there is a feature called callback
function. This feature uses Pointers to Functions to pass
them as parameters to other functions. Delegate is a
similar feature but it is more type safe, which stands as a
stark contrast with C++ function pointers. A delegate can
hold reference/s to one more more functions and invoke them
as and when needed.
Any delegate is inherited from base delegate class of .NET
class library when it is declared. This can be from either
of the two classes from System.Delegate or
System.MulticastDelegate
If the delegate contains a return type of void, then it is
automatically aliased to the type of
System.MulticastDelegate
Events in c#
Delegate usefulness does not just lie in the fact that it
can hold the references to functions but in the fact that
it can define and use function names at runtime and not at
compile time. A large goal of design delegates is their
applicability in events model of .Net. Events are the
actions of the system on user manipulations (e.g. mouse
clicks, key press, timer etc.) or any event triggered by
the program
Example can be seen at
http://www.codersource.net/csharp_delegates_events.html
| Is This Answer Correct ? | 6 Yes | 2 No |
Post New Answer View All Answers
What is called method in c#?
Explain the Different types of configuration files in .net?
Which constructor is called first in c#?
What is the difference between internal and protected in c#?
How do you determine whether a string represents a numeric value?
What are the types of serialization?
What are immutable types in c#?
What is the difference between string and stringbuilder in c#?
What I can do with c#?
In howmany ways can you deploy an assembly?
What happens if the inherited interfaces have conflicting method names?
What is the difference between namespace and class?
What is value c#?
What is null in database?
what is scope of a protected internal member variable of a c# class