Paramaterless delegates!
In C#, a parameterless delegate can accept any (or no) parameters.
Action<DateTime, BitArray> foo = delegate {
Console.WriteLine ("foo");
};
You can use this to assign event handlers where you don't care about the sender or event args.
Button1.Form1.Click += delegate { /* do something */ };
Written by Tom Theisen
Related protips
1 Response
I didn't know that was valid. Thanks for the tip!
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Delegates
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#