Click here to Skip to main content
15,887,135 members
Home / Discussions / C#
   

C#

 
GeneralRe: Query on Delegate Pin
ashish712-Jul-12 7:53
ashish712-Jul-12 7:53 
GeneralRe: Query on Delegate Pin
OriginalGriff12-Jul-12 3:48
mveOriginalGriff12-Jul-12 3:48 
GeneralRe: Query on Delegate Pin
ashish712-Jul-12 3:58
ashish712-Jul-12 3:58 
GeneralRe: Query on Delegate Pin
OriginalGriff12-Jul-12 4:11
mveOriginalGriff12-Jul-12 4:11 
GeneralRe: Query on Delegate Pin
DaveyM6912-Jul-12 4:32
professionalDaveyM6912-Jul-12 4:32 
AnswerRe: Query on Delegate Pin
Abhinav S11-Jul-12 21:53
Abhinav S11-Jul-12 21:53 
QuestionConfusion Pin
nitish_0711-Jul-12 21:02
nitish_0711-Jul-12 21:02 
AnswerRe: Confusion Pin
Abhinav S11-Jul-12 21:41
Abhinav S11-Jul-12 21:41 
What you have read and understood is actually quite correct.

A delegate is a type that safely encapsulates a method, similar to a function pointer in C and C++. Unlike C function pointers, delegates are object-oriented, type safe, and secure. The type of a delegate is defined by the name of the delegate. A delegate encapsulates a method.

A delegate object is normally constructed by providing the name of the method the delegate will wrap, or with an anonymous Method. Once a delegate is instantiated, a method call made to the delegate will be passed by the delegate to that method. The parameters passed to the delegate by the caller are passed to the method, and the return value, if any, from the method is returned to the caller by the delegate. This is known as invoking the delegate. An instantiated delegate can be invoked as if it were the wrapped method itself.

E.g. In the example below, a delegate (with a string as parameter) is created and then invoked by using the handler.
The handler points to the actual method.

C#
public delegate void Del(string message);

// Create a method for a delegate.
public static void DelegateMethod(string message)
{
    System.Console.WriteLine(message);
}

// Instantiate the delegate.
Del handler = DelegateMethod;

// Call the delegate.
handler("Hello World");


Note: Text and example taken from http://msdn.microsoft.com/en-us/library/ms173172.aspx[^].
Build your own survey - http://www.factile.net

AnswerRe: Confusion Pin
OriginalGriff11-Jul-12 21:41
mveOriginalGriff11-Jul-12 21:41 
AnswerRe: Confusion Pin
BillWoodruff14-Jul-12 15:17
professionalBillWoodruff14-Jul-12 15:17 
General[SOLVED] Adding Forms to TabControl Pin
AmbiguousName11-Jul-12 18:27
AmbiguousName11-Jul-12 18:27 
AnswerRe: Adding Forms to TabControl Pin
BobJanova11-Jul-12 23:29
BobJanova11-Jul-12 23:29 
GeneralRe: Adding Forms to TabControl Pin
AmbiguousName12-Jul-12 0:13
AmbiguousName12-Jul-12 0:13 
GeneralRe: Adding Forms to TabControl Pin
BobJanova12-Jul-12 4:05
BobJanova12-Jul-12 4:05 
GeneralRe: Adding Forms to TabControl Pin
AmbiguousName12-Jul-12 20:11
AmbiguousName12-Jul-12 20:11 
GeneralExposing a queue as a public property Pin
JoeRip11-Jul-12 17:44
JoeRip11-Jul-12 17:44 
GeneralRe: Exposing a queue as a public property Pin
PIEBALDconsult11-Jul-12 19:50
mvePIEBALDconsult11-Jul-12 19:50 
GeneralRe: Exposing a queue as a public property Pin
Abhinav S11-Jul-12 19:59
Abhinav S11-Jul-12 19:59 
GeneralRe: Exposing a queue as a public property Pin
BobJanova11-Jul-12 23:27
BobJanova11-Jul-12 23:27 
GeneralRe: Exposing a queue as a public property Pin
JoeRip12-Jul-12 6:58
JoeRip12-Jul-12 6:58 
GeneralRe: Exposing a queue as a public property Pin
BobJanova12-Jul-12 23:41
BobJanova12-Jul-12 23:41 
GeneralRe: Exposing a queue as a public property Pin
PIEBALDconsult13-Jul-12 3:44
mvePIEBALDconsult13-Jul-12 3:44 
GeneralRe: Exposing a queue as a public property Pin
JoeRip13-Jul-12 8:35
JoeRip13-Jul-12 8:35 
GeneralRe: Exposing a queue as a public property Pin
PIEBALDconsult14-Jul-12 4:13
mvePIEBALDconsult14-Jul-12 4:13 
QuestionPost build event using XML Pin
manishsaiin11-Jul-12 5:58
manishsaiin11-Jul-12 5:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.