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;
        }

    }


 


}

你可能感兴趣的:(out)