0

In my programming i have a challenge..

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

now i need to convert those dictionary "values" to 'Double' array.

i tried like this,

string[] strn=dic.Values.ToArray();

but not working. can any one please resolve my problem. Thanks in advance.

kik
  • 247
  • 1
  • 5
  • 15
  • Duh, you're trying to store a collection of ints as an array, into an array of strings; of course that would never work. And what exactly do you mean by "double array"? Two arrays, or an array of doubles? – BoltClock Jun 08 '11 at 10:12

2 Answers2

7
double[] dd = dic.Values.Select(i => (double)i).ToArray();
manji
  • 47,442
  • 5
  • 96
  • 103
5

Try:

double[] strn = dic.Values.Select(v => (double)v).ToArray();

...and ignore people who are unkind enough to say "duh" :)

Steve Wilkes
  • 7,085
  • 3
  • 29
  • 32