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

C#

 
QuestionAlghoritms to executable Pin
conemajstor1-Jan-07 6:59
conemajstor1-Jan-07 6:59 
AnswerRe: Alghoritms to executable Pin
Colin Angus Mackay1-Jan-07 8:30
Colin Angus Mackay1-Jan-07 8:30 
AnswerRe: Alghoritms to executable Pin
Eric Georgiades1-Jan-07 21:07
Eric Georgiades1-Jan-07 21:07 
QuestionHow to change threadstate !!! Pin
asay1-Jan-07 5:20
asay1-Jan-07 5:20 
QuestionThread pooling Pin
Jeeva Jose1-Jan-07 1:55
Jeeva Jose1-Jan-07 1:55 
AnswerRe: Thread pooling Pin
Judah Gabriel Himango1-Jan-07 10:19
sponsorJudah Gabriel Himango1-Jan-07 10:19 
QuestionMaking a Virtual Oscilloscope Pin
Brycestro1-Jan-07 1:43
Brycestro1-Jan-07 1:43 
QuestionDifference between Delegates & Events ? Pin
circonian31-Dec-06 23:11
circonian31-Dec-06 23:11 
I know an Event is a special kind of delegate, but its the best fitting title I could think of.
I've been trying to learn about delegates & events. I've read tutorials, a book, & followed examples but I still have a question.

For an event, in short, it seems like we:
1) Declare our Delegate Class: public delegate void MeltdownHandler(object reactor, MeltdownEventArgs myMEA);
2) Create an event: public event MeltdownHandler OnMeltdown;
3) Tell some new Delegate Object to call [some_method], when the event is raised: myReactor.OnMeltdown += new MeltdownHandler([some_method]);
4) Call the event: OnMeltdown([whatever]);
5) Which calls the Delegate Object.
6) Which calls [some_method]

Why not just create a Delegate Object and call the Delegate Object directly which will call [some_method] (instead of raising the event) ?
1) Define our Delegate Class: public delegate void MeltdownHandler(object reactor, MeltdownEventArgs myMEA);
2) Create an Delegate Object of that type: MeltdownHandler myMeltdownHandler = new MeltdownHandler([some_method]);
3) Call that Delegate Object: myMetldownHandler([whatever]);
4) Which calls [some_method]

So what am I missing? Whats the benefit of creating & raising an event. By creating & directly calling a Delegate Object it seems like it still has the same effect, with less code. It still notifies another object that something has occurred.
AnswerRe: Difference between Delegates & Events ? Pin
Nader Elshehabi1-Jan-07 1:56
Nader Elshehabi1-Jan-07 1:56 
GeneralRe: Difference between Delegates & Events ? Pin
circonian2-Jan-07 13:21
circonian2-Jan-07 13:21 
AnswerRe: Difference between Delegates & Events ? Pin
J. Dunlap1-Jan-07 4:33
J. Dunlap1-Jan-07 4:33 
Questionread and display from txt file Pin
sunilticku31-Dec-06 22:29
sunilticku31-Dec-06 22:29 
AnswerRe: read and display from txt file Pin
KevinMac1-Jan-07 9:56
KevinMac1-Jan-07 9:56 
QuestionHow to fill a selected column from a table to Datagridview Pin
mwith31-Dec-06 20:44
mwith31-Dec-06 20:44 
QuestionLogin to server from code Pin
M.kh31-Dec-06 20:40
M.kh31-Dec-06 20:40 
QuestionReference book recommendations Pin
Glen Harvy31-Dec-06 17:28
Glen Harvy31-Dec-06 17:28 
AnswerRe: Reference book recommendations Pin
Colin Angus Mackay31-Dec-06 18:55
Colin Angus Mackay31-Dec-06 18:55 
QuestionSimple encyption/keys question - please pelase help :) Pin
Cormac M Redmond31-Dec-06 10:43
Cormac M Redmond31-Dec-06 10:43 
AnswerRe: Simple encyption/keys question - please pelase help :) Pin
Colin Angus Mackay31-Dec-06 16:27
Colin Angus Mackay31-Dec-06 16:27 
GeneralRe: Simple encyption/keys question - please pelase help :) [modified] Pin
Cormac M Redmond31-Dec-06 17:56
Cormac M Redmond31-Dec-06 17:56 
GeneralRe: Simple encyption/keys question - please pelase help :) Pin
Colin Angus Mackay31-Dec-06 18:44
Colin Angus Mackay31-Dec-06 18:44 
GeneralRe: Simple encyption/keys question - please pelase help :) Pin
Nader Elshehabi1-Jan-07 1:29
Nader Elshehabi1-Jan-07 1:29 
GeneralRe: Simple encyption/keys question - please pelase help :) Pin
Cormac M Redmond1-Jan-07 1:48
Cormac M Redmond1-Jan-07 1:48 
GeneralRe: Simple encyption/keys question - please pelase help :) Pin
Nader Elshehabi1-Jan-07 2:01
Nader Elshehabi1-Jan-07 2:01 
GeneralRe: Simple encyption/keys question - please pelase help :) Pin
Cormac M Redmond1-Jan-07 2:35
Cormac M Redmond1-Jan-07 2:35 

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.