Click here to Skip to main content
15,910,210 members
Home / Discussions / C#
   

C#

 
GeneralRe: Anonymous methods Pin
Christian Graus26-Jul-07 21:39
protectorChristian Graus26-Jul-07 21:39 
GeneralRe: Anonymous methods Pin
Malcolm Smart26-Jul-07 21:51
Malcolm Smart26-Jul-07 21:51 
GeneralRe: Anonymous methods Pin
Christian Graus26-Jul-07 22:01
protectorChristian Graus26-Jul-07 22:01 
AnswerRe: Anonymous methods Pin
szukuro26-Jul-07 21:51
szukuro26-Jul-07 21:51 
GeneralRe: Anonymous methods Pin
J4amieC26-Jul-07 22:07
J4amieC26-Jul-07 22:07 
GeneralRe: Anonymous methods Pin
Kevin McFarlane26-Jul-07 23:46
Kevin McFarlane26-Jul-07 23:46 
GeneralRe: Anonymous methods Pin
Michael Sync26-Jul-07 23:47
Michael Sync26-Jul-07 23:47 
GeneralRe: Anonymous methods Pin
szukuro27-Jul-07 1:06
szukuro27-Jul-07 1:06 
Michael Sync wrote:
The way I understand is that things that can be done with anonymous method can also be done with delegate. There is no particular case that has to be used the anonymous method.


Depends on how you view it. As I pointed out in my example, a regular delegate couldn't have accessed the local variable, so it could not have been done that way. Then again you can overcome this by simply declaring a class member for example so the regular delegate can access it. So yes, one way or another anything can be achieved with regular delegates as with their anonymous counterparts, however there are scenarios where one should be favored over the other.

Also a side note, in C# 3.0 you can use lamdba expressions, which are much shorter then anonymous methods (but are more or less the same thing, though the former can be built in run-time using expression trees). So you can write code like:
List<int> nonPrimeNumbers = numbers.FindAll(i => primeNumbers.Contains(i));
Pretty neat, don't you think?Smile | :)
GeneralRe: Anonymous methods Pin
Michael Sync27-Jul-07 1:29
Michael Sync27-Jul-07 1:29 
AnswerRe: Anonymous methods Pin
leppie27-Jul-07 3:22
leppie27-Jul-07 3:22 
Questionstring array Pin
Xmen Real 26-Jul-07 20:52
professional Xmen Real 26-Jul-07 20:52 
AnswerRe: string array Pin
Urs Enzler26-Jul-07 20:54
Urs Enzler26-Jul-07 20:54 
AnswerRe: string array Pin
Christian Graus26-Jul-07 20:59
protectorChristian Graus26-Jul-07 20:59 
GeneralRe: string array Pin
Martin#26-Jul-07 21:00
Martin#26-Jul-07 21:00 
AnswerRe: string array Pin
T.EDY26-Jul-07 21:27
T.EDY26-Jul-07 21:27 
GeneralRe: string array Pin
Xmen Real 26-Jul-07 23:04
professional Xmen Real 26-Jul-07 23:04 
GeneralRe: string array Pin
Martin#26-Jul-07 23:17
Martin#26-Jul-07 23:17 
GeneralRe: string array Pin
Xmen Real 27-Jul-07 2:22
professional Xmen Real 27-Jul-07 2:22 
GeneralRe: string array Pin
Martin#27-Jul-07 3:25
Martin#27-Jul-07 3:25 
GeneralRe: string array Pin
Xmen Real 27-Jul-07 4:48
professional Xmen Real 27-Jul-07 4:48 
GeneralRe: string array Pin
Martin#27-Jul-07 9:28
Martin#27-Jul-07 9:28 
GeneralRe: string array Pin
Xmen Real 27-Jul-07 18:07
professional Xmen Real 27-Jul-07 18:07 
GeneralRe: string array Pin
Martin#29-Jul-07 8:59
Martin#29-Jul-07 8:59 
QuestionHow to increment the value of "Current Queue Length" counter for .NET CLR LocksandThreads Pin
Vikas Pai26-Jul-07 20:35
Vikas Pai26-Jul-07 20:35 
QuestionDefault Parameters Pin
M. J. Jaya Chitra26-Jul-07 20:17
M. J. Jaya Chitra26-Jul-07 20:17 

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.