I've recently started working on a project in C# that requires the user to create as many instances of a class as they'd like. I've thought about two different ways to go about this.
1: Use a list of string arrays that contains the information held by the class. By this I mean when they create an instance of the class the data goes to a list so that I can re-use the same variable name.
// Initiating the class
dataSet1D currDataSet = new dataSet1D();
dataSet1D.name = txtName.Text;
dataSet1.length = Int32.Parse(txtIndex.Text);
// Creating the list of arrays
List<string[]> arrayList = new List<string[]>();
string[] strArray = new string[2];
strArray[0] = "name";
strArray[1] = "lengthAsString";
arrayList.Add(strArray);
(That was just some quick mock-up code, I'll obviously use better variable names on my actual project)
2: I could use dynamically named variables If they enter what they want as a name, I can name the instance that.
dataSet1D <dynamically named variable name> = new dataSet1D();
Dictionary<TKey, TValue>class.