Click here to Skip to main content
15,893,190 members
Home / Discussions / C#
   

C#

 
QuestionAccess database in winME Pin
neliocc11-Apr-06 9:20
neliocc11-Apr-06 9:20 
AnswerRe: Access database in winME Pin
Ed.Poore11-Apr-06 10:48
Ed.Poore11-Apr-06 10:48 
QuestionLooking for a base class with typeof? Pin
Andrew Stampor11-Apr-06 8:45
Andrew Stampor11-Apr-06 8:45 
AnswerRe: Looking for a base class with typeof? Pin
Robert Rohde11-Apr-06 8:50
Robert Rohde11-Apr-06 8:50 
GeneralRe: Looking for a base class with typeof? Pin
Andrew Stampor11-Apr-06 9:00
Andrew Stampor11-Apr-06 9:00 
AnswerRe: Looking for a base class with typeof? Pin
Guffa11-Apr-06 8:57
Guffa11-Apr-06 8:57 
GeneralRe: Looking for a base class with typeof? Pin
Andrew Stampor11-Apr-06 9:02
Andrew Stampor11-Apr-06 9:02 
QuestionDelegates Pin
MrEyes11-Apr-06 7:59
MrEyes11-Apr-06 7:59 
Apologies for the rather vague thread title, it is difficult to summarise this question.

I would like to make sure I havent broken any cardinal sins with the following implementation of a delegate. Essentially I have the following classes:

class MyClass
{
  public delegate void MyDelegate(string s)
  private object delegateObj;

  public MyClass(MyDelegate md)
  {
    this.delegateObj = md
  }

  public void DoSomething1(string s)
  {
    (this.delegateObj as MyDelegate).DynamicInvoke(new object[] { s });
  }
}

class Worker
{
  public void DoSomethingA()
  {
    MyClass.MyDelegate delegateObj = new MyClass.MyDelegate(MyFunction);
    MyClass mc = new MyClass(delegateObj)
    mc.DoSomething1("hello");
  }

  public void MyFunction(string s)
  {
    Console.WriteLine(s);
  }
}


The reason for this is that I dont want to have to pass the a reference to the delegate every time I call the DoSomething1 method.

public void DoSomething1(string s, MyDelegate md)
  {
    md(s)
  }


I couldnt find a way to store an instance of MyDelegate directly so in came the object and as cast and DynamicInvoke. While this seems to work fine, but as I am fairly inexperienced with delegates it just seems a little flakey to me.

An alternative would be this:

public void DoSomething1(string s)
  {
    (this.delegateObj as MyDelegate)(s)
  }


Although I have a feeling that under the hood this is exactly the same
AnswerRe: Delegates Pin
Robert Rohde11-Apr-06 8:48
Robert Rohde11-Apr-06 8:48 
QuestionShow tray app context menu on left-click? Pin
rickell11-Apr-06 7:54
rickell11-Apr-06 7:54 
AnswerRe: Show tray app context menu on left-click? Pin
Stefan Troschuetz11-Apr-06 22:12
Stefan Troschuetz11-Apr-06 22:12 
GeneralRe: Show tray app context menu on left-click? Pin
rickell18-Apr-06 4:13
rickell18-Apr-06 4:13 
GeneralRe: Show tray app context menu on left-click? Pin
Stefan Troschuetz18-Apr-06 23:29
Stefan Troschuetz18-Apr-06 23:29 
QuestionNeeds some help with hit testing Pin
truly_pringled11-Apr-06 7:19
truly_pringled11-Apr-06 7:19 
AnswerRe: Needs some help with hit testing Pin
_Bao_11-Apr-06 22:47
_Bao_11-Apr-06 22:47 
QuestionApplication exits unexpectedly and without errors Pin
Ricardo Mendes11-Apr-06 7:00
Ricardo Mendes11-Apr-06 7:00 
AnswerRe: Application exits unexpectedly and without errors Pin
_Bao_11-Apr-06 22:37
_Bao_11-Apr-06 22:37 
GeneralRe: Application exits unexpectedly and without errors Pin
Ricardo Mendes12-Apr-06 1:32
Ricardo Mendes12-Apr-06 1:32 
GeneralRe: Application exits unexpectedly and without errors Pin
_Bao_12-Apr-06 3:15
_Bao_12-Apr-06 3:15 
QuestionServer.MapPath() and AJAX Pin
Canastro11-Apr-06 6:58
Canastro11-Apr-06 6:58 
AnswerRe: Server.MapPath() and AJAX Pin
Judah Gabriel Himango11-Apr-06 11:13
sponsorJudah Gabriel Himango11-Apr-06 11:13 
QuestionC# timers Pin
zotdoc11-Apr-06 6:33
zotdoc11-Apr-06 6:33 
AnswerRe: C# timers Pin
leppie11-Apr-06 7:05
leppie11-Apr-06 7:05 
GeneralRe: C# timers Pin
zotdoc11-Apr-06 9:19
zotdoc11-Apr-06 9:19 
AnswerRe: C# timers Pin
Steve Maier11-Apr-06 8:07
professionalSteve Maier11-Apr-06 8:07 

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.