About delegates and events?

Answers were Sorted based on User's Feedback



About delegates and events?..

Answer / anil chauhan

In C# delegate is a class which contain the referance of a
function. or we can say that it is an function pointer.

and Event are the action performed by the user such as
mouse click elc.

Is This Answer Correct ?    6 Yes 0 No

About delegates and events?..

Answer / 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

More C Sharp Interview Questions

Why do we use Design Pattern in C#?

0 Answers   Impetus,


how to Create a datagridview control with check box column with 8rows in it, the maximum number of check boxes checked should be 3, when user checks the 4th corresponding message should be displayed and check box should be checked. User can uncheck the checked boxes Note: read-only property should not be used

0 Answers   HCL, NIC,


what is accessspecifier and explation each with example?

3 Answers  


what is the difference between finally and dispose methods?

3 Answers   HCL, Patni,


What language do desktop applications use?

0 Answers  






How is a string immutable?

0 Answers  


FOR EXAMPLE : CLASS Dotnet { } creating object: Dotnet dn=new Dotnet(); NOW THE QUESTION IS WHICH IS CALLED AS OBJECT ?EITHER dn OR new Dotnet() and CAN YOU PROVE YOUR ANSWER?????PLEASE REPLY...

1 Answers  


What is part of a method signature in c#?

0 Answers  


What's the implicit name of the parameter that gets passed into the set method/property of a class?

0 Answers  


How many aware interfaces are there?

0 Answers  


How does bubble sort work?

0 Answers  


List the fundamental oop concepts?

0 Answers  


Categories