A
A
Azimia Reg2020-08-03 18:18:12
C++ / C#
Azimia Reg, 2020-08-03 18:18:12

How to instantiate a class whose name is assigned by a for iterator?

The bottom line is that you need to iterate to create several instances of a class with different names.

for(int i = 0; i < 10; i++)
    {
         Class i = new Class();
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Korotenko, 2020-08-03
@Azimia

var classes = new List<Class>();
for(int i = 0; i < 10; i++)
    {
         classes.Add (new Class(){Name = i.ToString()});
    }

upgraded the condition of the cycle, the author you are doing funny setups
Pointless but purely at your request

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question