where to declare constructor of class in visual studio 2010 winforms project c++?
I nee开发者_如何学Pythond to call methods of class by pressing buttons, but I don't want to create new object every time. Besides, class creates list, so I do not want to create list again.
If your ArrayList will be used only inside the form class, make it a member of the class and initialize it in the form constructor:
public:
Form1(void)
{
InitializeComponent();
myList = gcnew ArrayList();
}
protected:
ArrayList^ myList;
As Konrad has pointed out, using Generics is preferred over the use of ArrayList. Something like this:
public:
Form1(void)
{
InitializeComponent();
x = gcnew System::Collections::Generic::List<String^>();
}
private:
System::Collections::Generic::List<String^>^ x;
精彩评论