#include "stdafx.h"
using namespace System;
using namespace System::Collections;
generic
ref class MyClass
{
public:
MyClass(int N)
{
m_Array = gcnew array(N);
}
static MyClass()
{
Console::WriteLine("static constructor");
}
void SetItem(int i, T t)
{
m_Array[i] = t;
}
T GetItem(int i)
{
return m_Array[i];
}
String^ GetItemStringValue(int i)
{
return m_Array[i]->ToString();
}
private:
array^ m_Array;
};
void main()
{
MyClass^ myClass = gcnew MyClass(10);
myClass->SetItem(0, "test");
Console::WriteLine("{0}", myClass->GetItem(0));
// Value class specialization
MyClass^ myClass2 = gcnew MyClass(10);
myClass2->SetItem(0, DateTime::Today);
Console::WriteLine("{0}", myClass2->GetItem(0));
}