Array initialization in Managed C++
问题 I wish to declare and initialize a 1D managed array of items. If it was C# code, I would write it like this: VdbMethodInfo[] methods = new VdbMethodInfo[] { new VdbMethodInfo("Method1"), new VdbMethodInfo("Method2") }; I am trying to write (well, actually, I'm writing a program generate) the same thing in managed C++... So far I have: typedef array<VdbMethodInfo^, 1> MethodArray; // How do I avoid pre-declaring the size of the array up front? MethodArray^ methods = gcnew MethodArray(2);