using System;
class MyBaseGenericClass<T> {
protected T myObject;
public MyBaseGenericClass(T o) {
myObject = o;
}
public virtual T getmyObject() {
Console.Write("Base's getmyObject(): " );
return myObject;
}
}
class MyGenericClass<T> : MyBaseGenericClass<T> {
public MyGenericClass(T o) : base(o) { }
public override T getmyObject() {
Console.Write("overide getmyObject(): ");
return myObject;
}
}
class Test {
public static void Main() {
MyBaseGenericClass<int> myObject = new MyBaseGenericClass<int>(8);
Console.WriteLine(myObject.getmyObject());
myObject = new MyGenericClass<int>(9);
Console.WriteLine(myObject.getmyObject());
}
}
|