what is the most efficient way of turning the list of values of a dictionary into an array
for example, if i have:
Dictionary where key is string and value is Foo
i want to get Foo[]
I am using VS 2005, C# 2.0
|
|||||||||||||||
|
Store it in a list. It is easier;
Of course if you specifically want it in an array;
|
||||
|
There is a ToArray() function on Values:
But I don't think its efficient (I haven't really tried, but I guess it copies all these values to the array). Do you really need an Array? If not, I would try to pass IEnumerable:
|
|||
|
If you would like to use linq, so you can try following:
I don't know which one is faster or better. Both work for me. |
|||
|