using System;
/*
* 证明
* 1.接口支持属性,且不用做特殊的多态标识
* 2.泛型完全支持多态。对多态的泛型表现和通常的多态完全一样。A<B>后的 t 的表现完全和多态的表现一样
*/
namespace 泛型
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
A<B> ab = new A<B>();
ab.t = new C();
ab.Fun();
Console.ReadLine();
}
}
interface IA
{
int Ma { set; get; }
}
class A<T> where T : IA
{
public T t;
public void Fun()
{
Console.WriteLine("Ma:"+t.Ma);
}
}
class B : IA
{
public B()
{
Ma = 5;
}
public int Ma{set;get;}
}
class C : B
{
public C()
{
Ma = 6;
}
}
}