C# Dynamic List Name

.net, c#

Solution

Create `Dictionary<string, List<string>>`:

var dict = new Dictionary<string, List<string>>();

dict["x1"] = new List<string>();

You can replace `"x1"` with variable.

Problem

I need to create few list in c# but want to name those list dynamically according to some condition. For example ``` List<string> x1= new List<string>(); List<string> x2 = new List<string>(); ``` The name "x1" and "x2" would come at runtime (probably from some file or something). Is there any way to achieve this ?

Original source

Related problems