mgroesink

mgroesink

  • NA
  • 19
  • 0

Create multiple instances of a class in a loop

Oct 8 2004 10:49 AM
In C# I create a class and from within a form I want to create multiple instances of that class in a loop. Suppose the name of the class is Emp. I know this doesn't work, but what is the way to fix this? for (int x=0 ; x<10 ; x++) { Emp "Emp" + x.ToString(x) = new Emp() } The problem is that I cannot use a string as above, but how do I give all of the new objects a unique name? And how can I access the newly created objects? Anyone there to help me? Thanks in advance. Marcel Roesink

Answers (3)