草庐IT

c# - 如何修复 'compiler error - cannot convert from method group to System.Delegate' ?

coder 2024-05-27 原文

 public MainWindow()
 {
    CommandManager.AddExecutedHandler(this, ExecuteHandler);
 }

 void ExecuteHandler(object sender, ExecutedRoutedEventArgs e)
 {
 }

错误 1 ​​参数 2:无法从“方法组”转换为“System.Delegate”

最佳答案

我猜有多个具有不同签名的 ExecuteHandler。只需将您的处理程序转换为您想要的版本:

CommandManager.AddExecuteHandler(this, (Action<object,ExecutedRoutedEventArgs>)ExecuteHandler);

关于c# - 如何修复 'compiler error - cannot convert from method group to System.Delegate' ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2479870/

有关c# - 如何修复 'compiler error - cannot convert from method group to System.Delegate' ?的更多相关文章

随机推荐