I have to do through Action like this:
Action acti开发者_如何学Goon = () => { ..// };
object o = action;
any way to do this:
object o = () =>{}; //this doesn't compile
What about:
object o = (Action) (() => { ... });
Though I don't really know why you'd want to store it as an object in the first place...
Weeeell, delegates are objects, but lambdas aren't.
This object o = (Action)(() => {});
will compile, but I don't know if it looks any better.
Another option, not all that different:
object o = new Action(() => { });
精彩评论