for (int i = 1; i <= numberofmatricesrequired; i++)
            string number = Convert.ToString(i);
            Matrix (matrixnumber+number) = new Matrix(matrixsize, matrixsize);

Basically I have x amount of matrices I need to establish of y by y size. I was hoping to name the matrices: matrixnumber1 matrixnumber2..matrixnumbern

I cannot use an array as its matrices I have to form.

Is it possible to use a string to name a string (or a matrix in this case)?

Thank you in advance for any help on this!

7 Years
Discussion Span
Last Post by PierlucSS

It's probably possible with reflection, however, why dont you store your matrix in a Collection called matrixcollection than use and indexer to grab which "number" you want.

Something like the following would be quite interresting for your case:

Dictionary<string, CustomObj> map = new Dictionary<string, CustomObj>(); 
foreach (string name in stringArray) 
    map[name] = new CustomObj(name); 

Edited by PierlucSS: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.