「c#」匿名メソッドのサンプル

書式
delegate void メソッド名(string addr)
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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

C#

Posted by arkgame