using System;
namespace 泛型继承之普通类继承泛型类
{
abstract class genClass<T>
{
protected T field;
public virtual T property
{
set { field=value; }
}
public genClass(int index) { }
public genClass(T t) { field = t; }
public abstract void method(T t);
}
class ordinaryClass : genClass<int>
{
public override int property
{
set
{
field = value;
}
}
public ordinaryClass(int t) : base(t){ property = t; }
public override void method(int t)
{
Console.WriteLine("property属性值为:{0}",base.field);
}
}
class Program
{
static void Main(string[] args)
{
int val = 152000;
ordinaryClass oc = new ordinaryClass(val);
oc.method(val);
Console.WriteLine("泛型类继承普通类演示成功!");
Console.Read();
}
}
}