TestDelegate testDelA = new TestDelegate(M); //C#1.0 explicite Method M must me declared
TestDelegate testDelB = delegate(string s) { Console.WriteLine(s); }; //C#2.0 inline "anonymos method
TestDelegate testDelC = (x) => { Console.WriteLine(x); }; // C# 3.0. lambda expr.
Action
In Windows Forms muss eine anonyme Methode noch zu einem MethodInvoker konvertiert werden:
this.Invoke(new MethodInvoker(delegate() { pgbStatus.Minimum = 0; }));
In Wpf zu einer Action:
Application.Current.Dispatcher.Invoke((Action)delegate
{
SetButtonsEnabled(true);
}, null);
No comments:
Post a Comment