I’ve got a list view and I have to populate it with states as the root nodes, and the cities as the child nodes. It’s a tedious task.
I have a Dictionary<String,List<String>> and doing it like this.
Dictionary<string, List<String>> locations = new Dictionary<string, List<String>>();
List<String> alabama = new List<String>();
alabama.add("city1");
alabama.add("city2");
alabama.add("city3");
....
locations.add("alabama",alabama);
....
Doing that for each state and city is getting annoying, and I just cant help but think there is an easier way.
Any thoughts?
Using collection initializer syntax and arrays instead of lists reduces the number of keystrokes a bit: