Avatar of jxbma
jxbma
Flag for United States of America

asked on 

How do I convert a .Net Dictionary<String,SomeClassType> to a List<SomeClassType>?

Hi:

I have a .Net dictionary defined to be the following:

Dictionary<String, SomeClassType> foo;

Open in new window



How do I convert the "Values" portion of this to a
List<SomeClassType>?

Open in new window


I would have thought that the following would work:

var foobar = foo.Values.ToList<SomeClassType>();

Open in new window


I get the following compiler error:
Error   14 'System.Collections.Generic.Dictionary<string,SomeClassType>.ValueCollection' does not contain a definition for 'ToList' and the best extension method overload 'System.Linq.ParallelEnumerable.ToList<TSource>(System.Linq.ParallelQuery<TSource>)' has some invalid arguments      



Thanks,
JohnB
C#.NET Programming

Avatar of undefined
Last Comment
Easwaran Paramasivam

8/22/2022 - Mon