Dictionary<string, List<string>> arrayDict = new Dictionary<string,
List<string>>();

List<string> FirstNames = new List<string>();
FirstNames.Add("xxx");
FirstNames.Add("yyy");
FirstNames.Add("zzz");
arrayDict.Add("FirstName", FirstNames);

...

List<string> FN = arrayDict["FirstName"];
string aName = FN[0];

On May 17, 3:33 am, Abhinav Bipnesh <[email protected]> wrote:
> Hi,
>
> Basically I have to make a buckets of data which will have some values. For
> example
>
> FirstName -> X-B-N
> LastName -> X-C-B
> Age-> C-D-F
> etc
> But I dont know how many such buckets I need to create before runtime. So
> one opition which I think will be efficient will be Dictionary of something
> like this
>
> Dictionary<string, List<string>> arrayDict = new Dictionary<string,
> List<string>>();
>
> But in the above case I am not getting how to insert data for the list in
> the dictionary. If you guys can suggest me some other data structure then
> please do.
> Thanks in advance.
> Abhinav
>
> On Sun, May 17, 2009 at 12:39 AM, Cerebrus <[email protected]> wrote:
>
> > First and foremost, an ArrayList contains Objects, not strongly typed
> > instances of any type.
>
> > Secondly, why is it not possible to create a List which contains
> > List<string> instances ? Why must you create an array, when you do not
> > know the bounds ?
>
> > On May 16, 11:50 pm, Abhinav Bipnesh <[email protected]>
> > wrote:
> > > Hi Guys,
>
> > > I have to create an array of ArrayList or List at runtime. The size of
> > > array will be known at runtime and that number of arraylist or list
> > > will need to create. One thing I know is that the type of data will be
> > > string so we can assume that these will be string ArrayList/List.
> > > So two question how to create and how to access data from this array
> > > of arraylist.
>
> > > Thanks in advance.
> > > Abhiav

Reply via email to