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?

匿名メソッド

Last updated at Posted at 2024-12-10

匿名メソッド
名前を持たないメソッド。
デリゲートを使用してメソッドをインスタンス化することで、メソッドを別途記述しなくてもよくなる

これまでは...

public deligate void MyDeli(string message);

piblic static void Message(string message)
{
 Console.WriteLine("message");
}

public static void Main()
{
 MyDeli del = Message;
 del("匿名メソッド");
}

匿名メソッドを使用すると

public daligate void MyDeli(string message);

public static void Main()
{
 MyDeli del =  delegate(string message) // 匿名メソッド採用
{
 Console.WriteLine("message");
};
 del("匿名メソッド");
}
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?