Sometimes I canโt understand the simplest things, Iโm sure itโs on my face, I just donโt see it. I am trying to create a delegate for a method in this simple class:
public static class BalloonTip
{
public static BalloonType BalType
{
get;
set;
}
public static void ShowBalloon(string message, BalloonType bType)
{
// notify user
}
}
Now this Action <> should create a delegate without declaring the keyword "delegate", did I understand correctly? Then:
private void NotifyUser(string message, BalloonTip.BalloonType ballType)
{
Action<string, BalloonTip.BalloonType> act;
act((message, ballType) => BalloonTip.ShowBalloon(message, ballType));
}
This does not compile. What for?
(By the way, the reason I need this delegate instead of calling ShowBalloon () directly is that the calls should be made from a thread other than the interface, so I decided that I needed the <> action)
Thank,
source
share