Create multiple instances of a class in a loop
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
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
bilnaadRank #2,152 · 654 pointsPosted Oct 10, 2004, 4:50 AM EDT
itaym0261 pointsPosted Oct 8, 2004, 7:47 AM EDT
fffd sdsd2 pointsPosted Jul 1, 2010, 1:57 AM EDT