[Solved] How to declare and initialize multiple variables (with different names) within a for loop without using arrays?


You cannot create dynamically named variables in C# (and I am with those who are wondering why you want to do that). If you don’t want to use an array, consider a Dictionary — it would perform better than an array in some circumstances.

Dictionary<string, int> values = new Dictionary<string, int>();
for (int i = 1; i <= 4; i++)
{
    values.Add("value" + i, 0);
}

value["value1"]; //retrieve from dictionary

solved How to declare and initialize multiple variables (with different names) within a for loop without using arrays?