A simple generic class hierarchy : Generic Class Hierarchy : Generics C# Source Code


Custom Search

C# Source Code » Generics » Generic Class Hierarchy »

 

A simple generic class hierarchy









    


using System;

class GenericClass<T> {
  T myObject;

  public GenericClass(T o) {
    myObject = o;
  }

  public T getmyObject() {
    return myObject;
  }
}

class GenericClass2<T> : GenericClass<T> {
  public GenericClass2(T o) : base(o) {
  }
}

class Test {
  public static void Main() {
    GenericClass2<string> g2 = new GenericClass2<string>("www.navioo.com");

    Console.WriteLine(g2.getmyObject());
  }
}
           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Generics
» Generic Class Hierarchy