Click here to Skip to main content
15,923,218 members
Home / Discussions / C#
   

C#

 
Questionproblem if network disconnected while FTP uploading Pin
Iftekhar Naim29-May-07 0:35
Iftekhar Naim29-May-07 0:35 
AnswerRe: problem if network disconnected while FTP uploading Pin
Shajeel29-May-07 2:02
Shajeel29-May-07 2:02 
GeneralRe: problem if network disconnected while FTP uploading Pin
Iftekhar Naim29-May-07 2:34
Iftekhar Naim29-May-07 2:34 
QuestionMSMQ Pin
vibhas198229-May-07 0:25
vibhas198229-May-07 0:25 
AnswerRe: MSMQ Pin
snorkie29-May-07 16:47
professionalsnorkie29-May-07 16:47 
GeneralRe: MSMQ Pin
vibhas198229-May-07 18:54
vibhas198229-May-07 18:54 
GeneralRe: MSMQ Pin
snorkie30-May-07 7:25
professionalsnorkie30-May-07 7:25 
QuestionQuestion about delegates Pin
Revant Jain29-May-07 0:22
Revant Jain29-May-07 0:22 
Hello

I had a question about named delegates. Now from my understanding named delegates can only hold references of a method that matches the signature of the delegate. I have a piece of code which is contrary to this statement.

Using System;

delegate int CountIt(int end);

class varCapture{

static CountIt counter()
{

int sum = 0;

CountIt ctObj = delegate(int end) {
for( int i = 0; i <= end; i++ )
{
Console.WriteLine(i);
sum += i;
}
return sum;
};
return ctObj;
}

public static void Main()
{

CountIt count = counter();

int result;

result = count(3);

}

Now the delegate of type CountIt must refer to a method that takes int as a parameter and returns int as a parameter.

CountIt count = counter();

In the following line the delegate count is pointing to the method with no parameters or return type. So I wanted to understand how is it possible?

Is this assignment possible because the counter() is returning a object of type CountIt(same as that of the delegate)? If so when CountIt count = counter(); is executed it calls counter() and then just initializes the CountIt object an return it, does it actually go into the anonymous method block code? If not why?

Thanks

Revant Jain
AnswerRe: Question about delegates Pin
Christian Graus29-May-07 0:30
protectorChristian Graus29-May-07 0:30 
QuestionMail merge fields in wordpad or pdf Pin
Farhan Ali29-May-07 0:18
Farhan Ali29-May-07 0:18 
QuestionMicrosoft Office PowerPoint Version error Pin
mmayur28-May-07 23:55
mmayur28-May-07 23:55 
QuestionFree .net Winform UI Library Pin
Gal Edvi28-May-07 23:34
Gal Edvi28-May-07 23:34 
AnswerRe: Free .net Winform UI Library Pin
originSH29-May-07 0:09
originSH29-May-07 0:09 
QuestionSAP .Net help Pin
sohne28-May-07 23:30
sohne28-May-07 23:30 
Questionhttpwebresponse Pin
TAREQ F ABUZUHRI28-May-07 22:38
TAREQ F ABUZUHRI28-May-07 22:38 
AnswerRe: httpwebresponse Pin
Martin#28-May-07 23:28
Martin#28-May-07 23:28 
GeneralRe: httpwebresponse Pin
Albert Dadze29-May-07 0:38
Albert Dadze29-May-07 0:38 
GeneralRe: httpwebresponse Pin
Martin#29-May-07 0:53
Martin#29-May-07 0:53 
Questionhttpweb rsponse Pin
TAREQ F ABUZUHRI28-May-07 22:08
TAREQ F ABUZUHRI28-May-07 22:08 
QuestionDotNetBar's tabControl Pin
jason_mf28-May-07 22:06
jason_mf28-May-07 22:06 
AnswerRe: DotNetBar's tabControl Pin
Martin#28-May-07 22:10
Martin#28-May-07 22:10 
GeneralRe: DotNetBar's tabControl Pin
jason_mf28-May-07 22:16
jason_mf28-May-07 22:16 
GeneralRe: DotNetBar's tabControl Pin
Martin#28-May-07 22:30
Martin#28-May-07 22:30 
GeneralRe: DotNetBar's tabControl Pin
jason_mf28-May-07 22:39
jason_mf28-May-07 22:39 
GeneralRe: DotNetBar's tabControl Pin
Martin#28-May-07 23:17
Martin#28-May-07 23: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.