トップ «前の日記(2010-12-07) 最新 次の日記(2010-12-09)» 編集

日々の破片

著作一覧

2010-12-08

_ C#の引数と返値

ちょっと気になったのでテスト。
public class Fun
{
    delegate int x();
    static x cx(int n)
    {
        int i = n * 10;
        return () => { return ++i; };
    }
    static x dx(x xx)
    {
        return () => { return xx(); };
    }
    public static void Main()
    {
        var fun1 = cx(10);
        System.Console.WriteLine(fun1());
        var fun2 = cx(20);
        System.Console.WriteLine(fun2());
        System.Console.WriteLine(fun1());
        System.Console.WriteLine(fun2());
        var fun3 = dx(fun2);
        System.Console.WriteLine(fun3());                
        System.Console.WriteLine(fun2());
        System.Console.WriteLine(fun3());                
    }
}
実行すると
C:\test>fun
101
201
102
202
203
204
205
特に問題なかった。

2003|06|07|08|09|10|11|12|
2004|01|02|03|04|05|06|07|08|09|10|11|12|
2005|01|02|03|04|05|06|07|08|09|10|11|12|
2006|01|02|03|04|05|06|07|08|09|10|11|12|
2007|01|02|03|04|05|06|07|08|09|10|11|12|
2008|01|02|03|04|05|06|07|08|09|10|11|12|
2009|01|02|03|04|05|06|07|08|09|10|11|12|
2010|01|02|03|04|05|06|07|08|09|10|11|12|
2011|01|02|03|04|05|06|07|08|09|10|11|12|
2012|01|02|03|04|05|06|07|08|09|10|11|12|
2013|01|02|03|04|05|06|07|08|09|10|11|12|
2014|01|02|03|04|05|06|07|08|09|10|11|12|
2015|01|02|03|04|05|06|07|08|09|10|11|12|
2016|01|02|03|04|05|06|07|08|09|10|11|12|
2017|01|02|03|04|05|06|07|08|09|10|11|12|
2018|01|02|03|04|05|06|07|08|09|10|11|12|
2019|01|02|03|04|05|06|07|08|09|10|11|12|
2020|01|02|03|04|05|06|07|08|09|10|11|12|
2021|01|02|03|04|05|06|07|08|09|10|11|12|
2022|01|02|03|04|05|06|07|08|09|10|11|12|
2023|01|02|03|04|05|06|07|08|09|10|11|12|
2024|01|02|03|

ジェズイットを見習え