C#4.0泛型中的out使用

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            B<string> b = new B<string>();
            b.TValue = "I'm B";
            Console.WriteLine(b.TValue);
            A<string> a = b;
            Console.WriteLine(a.TValue);
            A<object> a2 = b;
            Console.WriteLine(a2.TValue);

        }
    }

    interface A<out T>
    {
        T TValue
        {
            get;
        }
    }

    class B<T> : A<T>
    {
         public T TValue
        {
            get;
            set;
        }

    }


 


}

posted @ 2009-05-30 12:34  kiminozo  阅读(485)  评论(0编辑  收藏  举报