Creating class instance names at run-time generating error. [C#]

I am using this code to generate five instances to a Class at run-time, but it is giving error: Cannot use local variable ‘inum’ before it is declared.


public class MyClass
{
static int i=0;

class A
{
	public A()
	{ 

	}
}

public static void Run()
{
	string inum = "i";
	for (int j=1;j<=5;j++)
	{
		inum = inum + j.ToString();
		//Initialize Instance
		A inum = new A();
	}
}

}


It also gives error:

A local variable named ‘inum’ cannot be declared in this scope because it would give a different meaning to ‘inum’, which is already used in a ‘parent or current’ scope to denote something else.

in the line where instance is created.

You might want to look into collections, such as the good old fashioned array or List<T>. You can’t use a string to dynamically name instance variables, at least not in this way.