「c#」匿名メソッドのサンプル
書式
delegate void メソッド名(string addr)
使用例
using System;
delegate void delegatesample(string addr);
class Program
{
static void Main(string[] args)
{
delegatesample dg = (string st) => { Console.WriteLine("文字列: " + st ); };
dg("test address");
}
}
using System;
delegate void delegatesample(string addr);
class Program
{
static void Main(string[] args)
{
delegatesample dg = (string st) => { Console.WriteLine("文字列: " + st ); };
dg("test address");
}
}
using System; delegate void delegatesample(string addr); class Program { static void Main(string[] args) { delegatesample dg = (string st) => { Console.WriteLine("文字列: " + st ); }; dg("test address"); } }
結果
文字列: test address