Reputation: 111
So I'm going to be starting multiple instances of one of my C# scripts, but I will later need to be able to reference individual instances to terminate or modify properties within. For an example:
_numInputs = 5;
for(int i = 0; i < _numInputs; i++)
{
Input input = new Input();
}
How would I go about throwing the value of "i" onto the end of the instance label?
Input input[i] = new Input(); ??? lol I know that doesn't work but just to clarify my goal. Any help is appreciated. Thanks guys.
Upvotes: 0
Views: 47
Reputation: 13684
What you want is an array of Instance
:
Input[] inputs = new Input[_numInputs];
for(int i = 0; i < _numInputs; i++)
{
inputs[i] = new Input();
}
Upvotes: 1