V
vbMark
I'm stuck on this crazy problem. I need to get this list into this type
of dictionary object: Dictionary<string, List>
I have this collection passed to me named "items"
-Animal
Dog
Cat
Cow
-Food
Apple
Nut
Carrot
-Vehicle
Car
Boat
Train
The string part of the dictionary object needs to be the word with the
dash and the items below it needs to go into its corresponding list
object.
I need to do this for dual drop-down boxes so that when a dashed item is
selected in one drop-down I can populate the other drop-down box with its
corresponding list.
Here is a rough structure of how I started but of course it does not
work:
ContainersCollection items = new ContainersCollection();
Dictionary<string, List> myDict = new Dictionary<string, List>();
List<string> myList = new List<string>();
String ContainerName;
foreach (string item in items)
{
if (item.StartsWith("-"))
ContainerName = item;
else
myList.Add(item);
//Do something here???
myDict.Add(ContainerName, myList);
}
Any ideas?
Thanks!!!
Mark
of dictionary object: Dictionary<string, List>
I have this collection passed to me named "items"
-Animal
Dog
Cat
Cow
-Food
Apple
Nut
Carrot
-Vehicle
Car
Boat
Train
The string part of the dictionary object needs to be the word with the
dash and the items below it needs to go into its corresponding list
object.
I need to do this for dual drop-down boxes so that when a dashed item is
selected in one drop-down I can populate the other drop-down box with its
corresponding list.
Here is a rough structure of how I started but of course it does not
work:
ContainersCollection items = new ContainersCollection();
Dictionary<string, List> myDict = new Dictionary<string, List>();
List<string> myList = new List<string>();
String ContainerName;
foreach (string item in items)
{
if (item.StartsWith("-"))
ContainerName = item;
else
myList.Add(item);
//Do something here???
myDict.Add(ContainerName, myList);
}
Any ideas?
Thanks!!!
Mark