2
Answers

Instantiate a Class Multiple Times Dynamicly

Jay

Jay

15y
6.7k
1

Hi Everyone,

I was wondering if someone could help me.  I have a class that I need to instantiate multiple times depending on how much info there is.  I want to be able to do something like.......

myClass class1 = new MyClass();

myClass class2 = new MyClass();

myClass class3 = new MyClass();

...but I want to be able to set the class number, for example, something like....

int i = 0;

myClass class(i) = new MyClass(); //class(0)

i++;

myClass class(i) = new MyClass; //class(1);

i++;

Is there any way this can be done?

Any help would be appreciated.  Thanks in advance!

Jay

Answers (2)