Action<object, EventArgs> could not be cast to EventHandler?

后端 未结 5 1046
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-25 12:24

I was wiring up an event to use a lambda which needed to remove itself after triggering. I couldn\'t do it by inlining the lambda to the += event (no accessable variable to

5条回答
  •  情话喂你
    2020-12-25 12:41

    You can use an anonymous method instead:

    Event += (sender, e) =>
    {
         // Multiple lines
         // of code here
    };
    

提交回复
热议问题