LoginSignup
4
3

More than 5 years have passed since last update.

デリゲートをキャストする

Last updated at Posted at 2013-01-11

同じ引数、戻り値を持っていても以下のような代入はできません。

Program.cs
PropertyChangedEventHandler h1 = (_, __) => { };
EventHandler<PropertyChangedEventArgs> h2;

h2 = (EventHandler<PropertyChangedEventArgs>)h1;    // エラー

ugaya40 さんから正しいやり方を教えて頂きました。

Program.cs
PropertyChangedEventHandler h1 = (_, __) => { };
EventHandler<PropertyChangedEventArgs> h2;

h2 = new EventHandler<PropertyChangedEventArgs>(h1);    // OK
4
3
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3