Listing 5

generic <class T>
ref class Test
{
   T t;
public:
   Test(T a)
   {
      t = a;
   }
   String^ ToString() override
   {
      return String::Format("value is {0}", t->ToString());
   }
};
void main()
{
   Test<int>^ t1 = gcnew Test<int>(10);
   Console::WriteLine(t1);
   Test<String^>^ t2 = gcnew Test<String^>("hello");
   Console::WriteLine(t2); 
   Test<ArrayList^>^ t3 = gcnew Test<ArrayList^>(gcnew ArrayList);
   Console::WriteLine(t3); 
}