xiacy

导航

3.4.2 泛型类型的静态构造函数

    class Other<T>
    {
       public  class Inner<U, V>
        {
            static Inner()
            {
                Console.WriteLine("Other<{0}>.Inner<{1},{2}>", typeof(T).Name, typeof(U).Name, typeof(V).Name);
            }
            public static void DummyMethod() { }
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Other<int>.Inner<string, DateTime>.DummyMethod();
            Other<string>.Inner<int, int>.DummyMethod();
            Other<object>.Inner<string, object>.DummyMethod();
            Other<string>.Inner<string, object>.DummyMethod();
            Other<object>.Inner<object, string>.DummyMethod();
            Other<string>.Inner<int, int>.DummyMethod();
        }
    }

 

posted on 2012-05-01 13:46  xiacy  阅读(303)  评论(0编辑  收藏  举报