A non-generic class can be the base class of a generic derived class
using System;
class MyBaseClass {
int num;
public MyBaseClass(int i) {
num = i;
}
public int getnum() {
return num;
}
}
class MyGenericClass<T> : MyBaseClass {
T ob;
public MyGenericClass(T o, int i) : base (i) {
ob = o;
}
public T getob() {
return ob;
}
}
class HierDemo3 {
public static void Main() {
MyGenericClass<String> w = new MyGenericClass<String>("Hello", 7);
Console.WriteLine(w.getob());
Console.WriteLine(w.getnum());
}
}
Related examples in the same category