Click here to Skip to main content
15,907,497 members
Home / Discussions / C#
   

C#

 
GeneralRe: connectivity with database Pin
Wes Aday12-Jul-12 13:16
professionalWes Aday12-Jul-12 13:16 
GeneralRe: connectivity with database Pin
PIEBALDconsult13-Jul-12 3:47
mvePIEBALDconsult13-Jul-12 3:47 
AnswerRe: connectivity with database Pin
Bernhard Hiller15-Jul-12 22:46
Bernhard Hiller15-Jul-12 22:46 
QuestionEncrypt - Decrypt Pin
Midnight Ahri12-Jul-12 0:16
Midnight Ahri12-Jul-12 0:16 
AnswerRe: Encrypt - Decrypt Pin
Eddy Vluggen12-Jul-12 0:36
professionalEddy Vluggen12-Jul-12 0:36 
QuestionRe: Encrypt - Decrypt Pin
Midnight Ahri12-Jul-12 0:51
Midnight Ahri12-Jul-12 0:51 
AnswerRe: Encrypt - Decrypt Pin
Eddy Vluggen12-Jul-12 2:24
professionalEddy Vluggen12-Jul-12 2:24 
AnswerRe: Encrypt - Decrypt Pin
Midnight Ahri12-Jul-12 15:28
Midnight Ahri12-Jul-12 15:28 
GeneralRe: Encrypt - Decrypt Pin
BobJanova12-Jul-12 23:39
BobJanova12-Jul-12 23:39 
Questionhow to use use transparent proxy(local host) in middle of browser and destination server?? Pin
modipavan12-Jul-12 0:03
modipavan12-Jul-12 0:03 
AnswerRe: how to use use transparent proxy(local host) in middle of browser and destination server?? Pin
Eddy Vluggen12-Jul-12 0:40
professionalEddy Vluggen12-Jul-12 0:40 
QuestionCookie based authentication - calling a get cookie script - cookiecollection empty Pin
psycik11-Jul-12 23:20
psycik11-Jul-12 23:20 
AnswerRe: Cookie based authentication - calling a get cookie script - cookiecollection empty Pin
BobJanova11-Jul-12 23:45
BobJanova11-Jul-12 23:45 
GeneralRe: Cookie based authentication - calling a get cookie script - cookiecollection empty Pin
psycik11-Jul-12 23:51
psycik11-Jul-12 23:51 
GeneralRe: Cookie based authentication - calling a get cookie script - cookiecollection empty Pin
BobJanova13-Jul-12 4:14
BobJanova13-Jul-12 4:14 
QuestionQuery on Delegate Pin
ashish711-Jul-12 21:23
ashish711-Jul-12 21:23 
AnswerRe: Query on Delegate Pin
OriginalGriff11-Jul-12 21:37
mveOriginalGriff11-Jul-12 21:37 
GeneralRe: Query on Delegate Pin
Simon_Whale11-Jul-12 22:27
Simon_Whale11-Jul-12 22:27 
GeneralRe: Query on Delegate Pin
ashish711-Jul-12 22:29
ashish711-Jul-12 22:29 
GeneralRe: Query on Delegate Pin
DaveyM6911-Jul-12 22:48
professionalDaveyM6911-Jul-12 22:48 
GeneralRe: Query on Delegate Pin
OriginalGriff11-Jul-12 22:55
mveOriginalGriff11-Jul-12 22:55 
GeneralRe: Query on Delegate Pin
ashish711-Jul-12 23:13
ashish711-Jul-12 23:13 
GeneralRe: Query on Delegate Pin
Pete O'Hanlon11-Jul-12 23:23
mvePete O'Hanlon11-Jul-12 23:23 
GeneralRe: Query on Delegate Pin
BobJanova11-Jul-12 23:41
BobJanova11-Jul-12 23:41 
In .Net 1, you had to explicitly instantiate a delegate from a method:

EventHandler GameStarted = new EventHandler(GameStartedMethod);

void GameStartedMethod(object sender, EventArgs e) { ... }


Although clear, this was a bit messy and wasted a lot of time, so in .Net 2 and up you are allowed to implicitly cast the method, even though that appears to be assigning a method to a variable/property:
EventHandler GameStarted = GameStartedMethod;

void GameStartedMethod(object sender, EventArgs e) { ... }


You are also allowed to create an anonymous, inline method to assign to the delegate, using the delegate keyword:

EventHandler GameStarted = delegate(object sender, EventArgs e) { ... }


The delegate keyword approach allows you to omit the parameter list, if you don't need to refer to the parameters, which you often don't with event handlers:

EventHandler GameStarted = delegate { ... }


Finally, in .Net 3 and up, you can use lambda functions to create anonymous functions that can be used as a delegate:

EventHandler GameStarted = (sender, e) => { ... }


All of these are equivalent, and result in a delegate that points at a method. In the first two cases, that method has a name and can be called normally as well; in the others, it is anonymous and only exists in the context of the delegate.

When calling a delegate, normal method syntax is used.
GeneralRe: Query on Delegate Pin
Pete O'Hanlon11-Jul-12 22:50
mvePete O'Hanlon11-Jul-12 22:50 

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.