We recommend using Visual Studio 2017
This documentation is archived and is not being maintained.

How to: Use Managed Arrays as Template Type Parameters

This example shows how to use a managed array as a parameter to a template.

// mcppv2_template_type_params.cpp
// compile with: /clr
using namespace System;
template <class T> 
class TA {
   array<array<T>^>^ f() {
      array<array<T>^>^ larr = gcnew array<array<T>^>(10);
      return larr;

int main() {
   int retval = 0;
   TA<array<array<Int32>^>^>* ta1 = new TA<array<array<Int32>^>^>();
   array<array<array<array<Int32>^>^>^>^ larr = ta1->f();
   retval += larr->Length - 10;
   Console::WriteLine("Return Code: {0}", retval);


Return Code: 0