[Solved] C# Declare multiple dynamically named variables [duplicate]


Don’t try to use dynamically named variables. That’s simply not how variables work in C#.

Use an array of lists:

List<string>[] user = new List<string>[infoForUserSessions.Count];

for (int i = 0; i < infoForUserSessions.Count; i++) {
  user[i] = new List<string>();
}

If the number of sessions can change, you would use a List<List<string>> instead, so that you can add lists to it when you add items to the infoForUserSessions list.

2

solved C# Declare multiple dynamically named variables [duplicate]