Reputation: 83
I am new to C# but have school project that i am working on and need some guidance. I have multiple arrays which i termed array1, array2, array3 , array4 and so on till array9. Now the user is entering digits into input box and i am splitting the input like 543 into 5 4 3 and i want to dynamically call
array5 array4 array3. So basically show contents of these arrays in console.
string value = input.Text.ToString();
foreach (string s in Array[value[0]])
{
-- will loop through all values of array and out put
foreach (string s in Array[value[1]])
{
-- will loop through all values of array and out put
foreach (string s in Array[value[2]])
{
-- will loop through all values of array and out put
}
}
}
How do i accomplish this ? Please help
Upvotes: 1
Views: 647
Reputation: 3620
Try
var arrays = new List<int[]>(){array1,....,array9};
and then if you have 5, 4, 3 you can call arrays like
arrays[4], arrays[3], arrays[2]
Upvotes: 2