0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

[メモ]C# イベントの理解

Last updated at Posted at 2023-02-27

C# イベントの内容を理解するためいろいろ調べました。

イベントハンドラとは、特定のイベントが発生した際に行う"処理"のことです。
イベントハンドラは”デリゲート”なんです。
イベントが発生したときに、デリゲートで渡した処理が勝手に走ってくれます。

デリゲートは、「同じ戻り値の型で同じ引数の型を持つメソッドを代入できる」
なので、イベントハンドラと同じ型の関数を作って、それを代入すればイベント発生時にその処理を実行してくれるというわけなんです。

Visual Studio を使うなら、イベントを設定したいコントロールのプロパティの「イベント」ボタン(雷状)を押して、設定したいイベント項目を探して、項目の右の欄にダブルクリックすると、イベント関数が自動的に追加される。

参考サイト:
https://itthestudy.com/c-sharp-event-handler/

0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?