List Info

Thread: Convert Dictionary<> to List<>




Convert Dictionary<> to List<>
user name
2006-06-03 06:17:47
If each value could expand to more than one item in the
List<>

I have a structure which hold a collection of dependant
items I'd like the
list to be the item and also any dependents. So the
Dictionary can have 5
items however the list must contain the five items along
with the dependant
items each item holds.

I suppose I'll have to iterate over the dictionary and
simply build up the
list<>

Thanks.

-----Original Message-----
From: Discussion of development on the .NET platform using
any managed
language [mailtoOTNET-CL
RDISCUSS.DEVELOP.COM] On Behalf Of gregory young
Sent: Saturday, June 03, 2006 4:08 PM
To: DOTNET-CLRDISCUSS.DEVELOP.COM
Subject: Re: [DOTNET-CLR] Convert Dictionary<> to
List<>

I think this should work for you.


Dictionary<string, int> dictionary = new
Dictionary<string, int>();

dictionary.Add("foo", 2);

dictionary.Add("bar", 1);

IList<int> foo = new
List<int>(dictionary.Values);

I believe this is also the wrong list to be posting such
questions to ...
the Microsoft newsgroups would probably be a better
alternative for you.

Cheers,

Greg Young

On 6/3/06, Robert Rolls <implatformnetspace.net.au> wrote:
>
> I'd like to convert the Dictionary Values to a
List<> anybody know any
> magic
> .net classes/code?
>
>
>
> Rob.
>
>
> ===================================
> This list is hosted by DevelopMentor(r)  http://www.develop.com
>
> View archives and manage your subscription(s) at
> http://discuss.develop.com

>



--
If knowledge can create problems, it is not through
ignorance that we can
solve them.

Isaac Asimov

===================================
This list is hosted by DevelopMentorR  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com


===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )