P
Peter Duniho
I was reminded in a recent post
(http://groups.google.com/group/microsoft.public.dotnet.framework/msg/e649e992db857691?dmode=source)
that in C# one can use anonymous delegates without explicitly creating a
new delegate instance. However, I still run into situations in which the
compiler complains.
For example, I get a compiler error here:
Invoke(delegate() { /* some code */ });
which is fixable like this:
Invoke(new MethodInvoker(delegate() { /* some code */ }));
What gives? Is this a compiler version difference? Something about the
specific context? In what cases are you actually allowed to not contain
the anonymous delegate in a constructor for an actual delegate type, and
why doesn't that apply in the above example?
Pete
(http://groups.google.com/group/microsoft.public.dotnet.framework/msg/e649e992db857691?dmode=source)
that in C# one can use anonymous delegates without explicitly creating a
new delegate instance. However, I still run into situations in which the
compiler complains.
For example, I get a compiler error here:
Invoke(delegate() { /* some code */ });
which is fixable like this:
Invoke(new MethodInvoker(delegate() { /* some code */ }));
What gives? Is this a compiler version difference? Something about the
specific context? In what cases are you actually allowed to not contain
the anonymous delegate in a constructor for an actual delegate type, and
why doesn't that apply in the above example?
Pete