Click here to Skip to main content
15,915,702 members
Home / Discussions / C#
   

C#

 
AnswerRe: C sharp Pin
4a616e25-Nov-14 10:11
4a616e25-Nov-14 10:11 
AnswerRe: C sharp Pin
V.27-Nov-14 1:58
professionalV.27-Nov-14 1:58 
QuestionC# - Read App.Config file Pin
Member 1123932724-Nov-14 20:48
Member 1123932724-Nov-14 20:48 
AnswerRe: C# - Read App.Config file Pin
Richard MacCutchan24-Nov-14 21:38
mveRichard MacCutchan24-Nov-14 21:38 
GeneralRe: C# - Read App.Config file Pin
Member 1123932725-Nov-14 22:19
Member 1123932725-Nov-14 22:19 
GeneralRe: C# - Read App.Config file Pin
Richard MacCutchan25-Nov-14 22:54
mveRichard MacCutchan25-Nov-14 22:54 
AnswerRe: C# - Read App.Config file Pin
BillWoodruff25-Nov-14 4:20
professionalBillWoodruff25-Nov-14 4:20 
GeneralC# WPF Move - Rotate - Zoom Image Pin
LamThanhNghia24-Nov-14 13:54
LamThanhNghia24-Nov-14 13:54 
GeneralRe: C# WPF Move - Rotate - Zoom Image Pin
Dave Kreskowiak24-Nov-14 16:52
mveDave Kreskowiak24-Nov-14 16:52 
GeneralRe: C# WPF Move - Rotate - Zoom Image Pin
SledgeHammer0124-Nov-14 17:00
SledgeHammer0124-Nov-14 17:00 
GeneralRe: C# WPF Move - Rotate - Zoom Image Pin
Dave Kreskowiak24-Nov-14 17:07
mveDave Kreskowiak24-Nov-14 17:07 
GeneralRe: C# WPF Move - Rotate - Zoom Image Pin
SledgeHammer0124-Nov-14 17:12
SledgeHammer0124-Nov-14 17:12 
QuestionComo reproducir 2 videos sin cuadros negros entre ellos Pin
Member 1117759324-Nov-14 4:07
Member 1117759324-Nov-14 4:07 
AnswerRe: Como reproducir 2 videos sin cuadros negros entre ellos Pin
den2k8824-Nov-14 4:17
professionalden2k8824-Nov-14 4:17 
QuestionPDF ti HTML Pin
nitin_ion23-Nov-14 23:38
nitin_ion23-Nov-14 23:38 
AnswerRe: PDF ti HTML Pin
Richard MacCutchan24-Nov-14 0:17
mveRichard MacCutchan24-Nov-14 0:17 
QuestionC sharp Delegate Pin
Sarita S23-Nov-14 22:30
Sarita S23-Nov-14 22:30 
AnswerRe: C sharp Delegate Pin
Kornfeld Eliyahu Peter23-Nov-14 22:53
professionalKornfeld Eliyahu Peter23-Nov-14 22:53 
AnswerRe: C sharp Delegate Pin
Pete O'Hanlon24-Nov-14 0:11
mvePete O'Hanlon24-Nov-14 0:11 
AnswerRe: C sharp Delegate Pin
hassan faghihi24-Nov-14 1:17
professionalhassan faghihi24-Nov-14 1:17 
delegate are anonymous methods, same to what you do with lambda expression, before lambda it were available on begin C# versions....

So, you can do several thing through this:

1. Generate a new method inside an other method, once you need it, like:
Thread t = new Thread(new ThreadStart(delegate(){ ... } ) );
t.Start();

as you see 'delegate(){..}' is equal to the longer version of lambda; ()=>{...}

2. the other use is to pass a method to a function, That's same to what MethodInvoker do for concurrent programming, on win form application, which if you don't you may cause cross-thread exception.

if (this.InvokeRequired)
{
Invoke(new MethodInvoker(delegate()
{
...
}));
}

,
so you may come to a place where you write a method, which need something right in middle of code which you don't know, and the user may need to choose what code should be run...

so you define a delegate function (mean you give it a name and sets its signature)
then you use that as a input parameter, so you can use that function reference to call the function, user provide for you:

here is a sample:

public delegate int MyInvoker(int a, int b);

public void MyMethod(MyInvoker operation, int a, int b)
{
int result = operation(a, b);
}

Then the user may call your method like this:

MyMethod( (a,b)=>a+b, 1, 2);

or this:

private void sum(int a, int b)
{
return a+ b;
}

MyMethod(sum, 1, 2);

or may he use a deleagate:
delegate (a,b){return a+b}
as the input parameter.

NOTE: ThreadStart is a delegate too, it's same to MethodInvoker, i just tried to make different sample .
GeneralRe: C sharp Delegate Pin
Sarita S24-Nov-14 2:35
Sarita S24-Nov-14 2:35 
QuestionCapturing Data from an Excel Spreadsheet Pin
JimmyMac9123-Nov-14 11:45
JimmyMac9123-Nov-14 11:45 
AnswerRe: Capturing Data from an Excel Spreadsheet Pin
PIEBALDconsult23-Nov-14 12:23
mvePIEBALDconsult23-Nov-14 12:23 
GeneralRe: Capturing Data from an Excel Spreadsheet Pin
JimmyMac9123-Nov-14 16:01
JimmyMac9123-Nov-14 16:01 
GeneralRe: Capturing Data from an Excel Spreadsheet Pin
Mycroft Holmes23-Nov-14 18:27
professionalMycroft Holmes23-Nov-14 18:27 

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.